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

feat: add realm /r/demo/math_eval #965

Merged
merged 10 commits into from
Sep 16, 2023
Merged

feat: add realm /r/demo/math_eval #965

merged 10 commits into from
Sep 16, 2023

Conversation

schollz
Copy link
Contributor

@schollz schollz commented Jul 10, 2023

This eval realm is capable of evaluating 32-bit integer expressions as they would appear in Go. For example, you can use this package (and realm) to evaluate an expression like "(32*32+4)-1" when presented as a string.

This could have several applications. This current "eval" realm is simply demonstrating it as a 32-bit integer calculator.

I would like to also add floats, but it seems strconv.ParseFloat is not available yet.

In the future I would like to use the int32 version of this package in the bytebeat realm (#840) which could then utilize this library to generate audio directly from string expressions, instead of programmed realms - which ultimately gets closer to an audio NFT platform where expressions are uploaded if they are parsed correctly.

To test, you can just add the eval package and realm:

> gnokey maketx addpkg --pkgpath "gno.land/p/demo/math_eval_int32" \
    --pkgdir "examples/gno.land/p/demo/math_eval/int32" \
    --deposit 100000000ugnot --gas-fee 1000000ugnot \
    --gas-wanted 2000000 --broadcast --chainid dev --remote localhost:26657 \
    YOURKEY
> gnokey maketx addpkg --pkgpath "gno.land/r/demo/math_eval" \
    --pkgdir "examples/gno.land/r/demo/math_eval" \
    --deposit 100000000ugnot --gas-fee 1000000ugnot \
    --gas-wanted 2000000 --broadcast --chainid dev --remote localhost:26657 \
    YOURKEY

Then open up to localhost:8888/r/demo/math_eval and try expressions in the URL query, like localhost:8888/r/demo/math_eval:1+1.

image

Checklists...

Contributors Checklist

  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

Maintainers Checklist

  • Checked that the author followed the guidelines in CONTRIBUTING.md
  • Checked the conventional-commit (especially PR title and verb, presence of BREAKING CHANGE: in the body)
  • Ensured that this PR is not a significant change or confirmed that the review/consideration process was appropriate for the change

This realm adds a lexer/parser for integer expressions
@schollz schollz requested a review from a team as a code owner July 10, 2023 22:10
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Jul 10, 2023
@moul
Copy link
Member

moul commented Jul 12, 2023

Can you rename this realm to something else than « eval », maybe « bc » to match the Unix utility, or « math_eval ». Up to you.

@schollz
Copy link
Contributor Author

schollz commented Jul 12, 2023

@moul yes, no problem! math_eval is good - clear and concise.

@moul moul changed the title feat: add realm /r/demo/eval feat: add realm /r/demo/math_eval Jul 12, 2023
Copy link
Contributor

@harry-hov harry-hov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss gno.mod files :)

@moul
Copy link
Member

moul commented Jul 20, 2023

I miss gno.mod files :)

@harry-hov, we need an explicit CI check for this.

Edit: started working on it here: #981

@moul moul mentioned this pull request Jul 20, 2023
15 tasks
moul added a commit that referenced this pull request Jul 31, 2023
This PR introduces a new `gno lint` subcommand, currently focused on
checking for the presence of a `gno.mod` file in a package, and it's
linked with the CI. In the future, we plan to expand `gno lint` to
support additional checks, enhancing its utility for developers and CI
integration.

Addresses #850
Addresses #927
Related with
#965 (comment)

Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Miloš Živković <milos@zmilos.com>
Doozers pushed a commit to Doozers/gno that referenced this pull request Aug 31, 2023
This PR introduces a new `gno lint` subcommand, currently focused on
checking for the presence of a `gno.mod` file in a package, and it's
linked with the CI. In the future, we plan to expand `gno lint` to
support additional checks, enhancing its utility for developers and CI
integration.

Addresses gnolang#850
Addresses gnolang#927
Related with
gnolang#965 (comment)

Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Miloš Živković <milos@zmilos.com>
@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 8, 2023
@moul moul merged commit 5636546 into gnolang:master Sep 16, 2023
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants