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

[Feature request] Support for conditional operator a ? b : c #50

Open
dmathisen opened this issue Aug 2, 2022 · 3 comments
Open

[Feature request] Support for conditional operator a ? b : c #50

dmathisen opened this issue Aug 2, 2022 · 3 comments

Comments

@dmathisen
Copy link

It would be great to support conditional expressions (like "if statements").

Similar to math.js "Conditional expression" seen here
https://mathjs.org/docs/expressions/syntax.html

image

@bugwheels94
Copy link
Owner

mathjs has their own parser, AST etc and all while this library is just a modified version of dijkstra's algorithm. > < == etc symbols i can implement but boolean ? number : number. it means if boolean ? X should give X or boolean and X:Y should give Y if X = boolean or X if X != boolean. I will think and try my best about it in coming weekend or so..

@dmathisen
Copy link
Author

No problem - it sounds like a pretty complicated feature (do you allow nested "if" conditionals?).
1 > 2 ? 3 : 2 < 4 ? 5 : 6 => 3
1 < 2 ? 3 : 2 < 4 ? 5 : 6 => 5

It looks like it can get complicated and it's not a rush for me (I figured out a workaround for now).
Thank you for responding, regardless.

@marcusig
Copy link

Hi there,
I would like to vote for this feature, if is possible!
Thanks for the great work with this :)

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

3 participants