Support for boolean ops (double &&, ||) #2722
Replies: 6 comments
-
Yeah, I understand that it would be convenient to have logical operators The expression parser though tries to offer a math friendly syntax in the first place, not perse a JavaScript compatible one, though being able to keep the syntax consistent with JavaScript and Matlab for example is definitely a pre. I think the current logical operators |
Beta Was this translation helpful? Give feedback.
-
I agree that the default syntax should be math.alias({
operators: {
and: '&&',
or: '||'
},
functions: {
log: 'ln',
log10: 'log'
}
})
e1 = math.parse('A && B')
e1.toString() // 'A && B'
e2 = math.parse('log(10)+ln(e)')
e2.eval() // 2 |
Beta Was this translation helpful? Give feedback.
-
Making it possible to let people configure their own behavior is an interesting idea. In general though I think that "less is more", and more ways to do the same thing complicates an API, so I'm a bit careful and reserved in that regard.
:D |
Beta Was this translation helpful? Give feedback.
-
Hi, Consider the example following example. I have a variable a that can be either undefined, an empty string or a number.
Using a short circuit operator in such a case would make the expression a lot easier. |
Beta Was this translation helpful? Give feedback.
-
Yes! That would would be very nice change/improvement. We already implemented this for the conditional operation ( |
Beta Was this translation helpful? Give feedback.
-
simple solution is just do string substitution
|
Beta Was this translation helpful? Give feedback.
-
This is a JS library, after all :) Bites me almost every time I try to do an AND or OR
Beta Was this translation helpful? Give feedback.
All reactions