You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you do a subtraction with a 0 in the list of values to subtract, the results is incorrect.
Example: {"-": [10, 0, 100]} should be -90 but it returns 10 for some reason
The text was updated successfully, but these errors were encountered:
It's actually ignoring the third arg. In the docs https://jsonlogic.com/operations.html#arithmetic----- we say because + and * are associative, they take 1-to-n arguments. - only takes one arg (make negative) and two args (subtract) it does not process args after the second.
Here's the relevant snippet of code, comparing - to +. I don't think it's covered one way or the other by unit tests, arguably we could make it take a list and use a reducer, but I'm not sure its "intuitive"
Ah, I see. Thanks for the clarification @jwadhams
I think it would be useful to do subtraction with more than 2 values.
The workaround I suppose is to nest them like {"-": [{"-": [10, 0]}, 100]}
If you do a subtraction with a 0 in the list of values to subtract, the results is incorrect.
Example:
{"-": [10, 0, 100]}
should be -90 but it returns 10 for some reasonThe text was updated successfully, but these errors were encountered: