Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_empty_word procedure to the standard library #1483

Open
bobbinth opened this issue Sep 9, 2024 · 1 comment
Open

Add is_empty_word procedure to the standard library #1483

bobbinth opened this issue Sep 9, 2024 · 1 comment
Labels
enhancement New feature or request stdlib Related to Miden standard library

Comments

@bobbinth
Copy link
Contributor

bobbinth commented Sep 9, 2024

Frequently, we need to check if the word at the top of the stack is "empty" (i.e., consists of all zeros). There are several ways of doing this and it would be good to have a single canonical way so that people don't have to reinvent the wheel. Here is one proposal:

#! Inputs: [WORD, ...]
#! Outputs: [is_empty, ...]
export.is_empty_word
    eq.0 swap eq.0 and swap eq.0 and swap eq.0 and
end

This would require 10 cycles.

We could also provide a version of this which does not drop the word from the stack.

This could probably go into the sys module of the standard library.

@bobbinth bobbinth added enhancement New feature or request stdlib Related to Miden standard library labels Sep 9, 2024
@bobbinth
Copy link
Contributor Author

Seems like we already have is_empty_word procedure in std::utils module - but it works slightly differently from the above (it does not drop the word) and is also not documented.

I think we should rename the current is_empty_word into something like is_empty_word_cloned and add is_empty_word with the above implementation (alternatively, we can keep the current name and the new one could be called is_empty_word_dropped).

We should also document std::utils module or maybe move these procedures to std::sys module (and also document them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stdlib Related to Miden standard library
Projects
None yet
Development

No branches or pull requests

1 participant