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

Support Polish Notation #19

Open
ghost opened this issue Oct 20, 2020 · 5 comments
Open

Support Polish Notation #19

ghost opened this issue Oct 20, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented Oct 20, 2020

Supporting Polish Notation would be a cool addition to this library in my opinion. Or a polish notation evaluation library may be a idea for another math library? But I dont know how something like this would be done. Just throwing the idea out here.

https://en.wikipedia.org/wiki/Polish_notation

Thanks for reading my issue!

@narrowtux
Copy link
Owner

I think it could be implemented as another parse function, like parse_polish or so. The resulting AST would be the same (as it's elixir AST anyway).

@ghost
Copy link
Author

ghost commented Oct 20, 2020

I think it could be implemented as another parse function, like parse_polish or so. The resulting AST would be the same (as it's elixir AST anyway).

Do you like the idea of having this in your library? Or would it be something that would be at application level?
Update: I think I am going to create add-on library for fun and call it PolishAbacus or smth like this. It would would have a function that would parse to a syntax tree that could be used with eval etc

@narrowtux
Copy link
Owner

I'll gladly accept a PR that adds a second function to parse a different syntax into the same internal representation (the AST). If you need any pointers, feel free to ask. I think writing your own parser is an excellent excercise.

@narrowtux
Copy link
Owner

narrowtux commented Oct 20, 2020

You can probably get away with copying and then modifying this file: https://github.com/narrowtux/abacus/blob/master/src/math_term_parser.yrl

This is in erlangs yecc language: https://erlang.org/doc/man/yecc.html

When it's compiled, a module named :math_term_parser will be available.

@ghost
Copy link
Author

ghost commented Oct 20, 2020

Thanks, I will try it out and send a PR! :)

@ghost ghost mentioned this issue Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant