Proposal - min
, max
and Arithmetic Chaining Touchup
#34
TotalTechGeek
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
Self +1 Current Votes
|
Beta Was this translation helpful? Give feedback.
0 replies
-
My thoughts:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
Okay folks!
JSON Logic has
min
andmax
operators. We should more explicitly define its expected behaviors.In the past, we defined: https://github.com/orgs/json-logic/discussions/21 (Arithmetic)
And recently we defined: https://github.com/orgs/json-logic/discussions/28 (Remove Sugaring + Add Chaining Concept)
Proposal
In previous discussions, we've decided we'd like to avoid coercion in most operators, so
min
andmax
will be defined to only work with numbers.I'd like to define min and max with the following:
{ op: n }
is the same as{ op: [n] }
Min will return the smallest number provided to it.
Max will return the largest number provided to it.
Infinity
and-Infinity
are currently being considered precision-related constructs, thus are relegated to the implementation to handle idiomatically if encountered.So this proposal defines:
I'd also like to touch up the definitions for the Arithmetic Operators (
+
,-
,/
,*
,%
), and give them the following modifiers:{ op: n }
is the same as{ op: [n] }
Tests
max
min
Arithmetic Tests
I will add these to their respective files, but I'm grouping them together for this:
Controvery Warnings
This test suite uses
merge
andmap
even though we haven't re-evaluatedmerge
andmap
quite yet. However, it is being used in the same way that it was used intests.json
, so I'd argue these behaviors are already defined.Beta Was this translation helpful? Give feedback.
All reactions