Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,19 @@
# modes/0 produces an array of [value, count]
# in increasing order of count:
def modes:
sort | reduce .[] as $i ([];
# state variable is an array of [value, count]
if length == 0 then [ [$i, 1] ]
elif .[-1][0] == $i then setpath([-1,1]; .[-1][1] + 1)
else . + [[$i,1]]
end )
| sort_by( .[1] );
# mode/0 outputs a stream of the modal values;
# if the input array is empty, the output stream is also empty.
def mode:
if length == 0 then empty
else modes as $modes
| $modes[-1][1] as $count
| $modes[] | select( .[1] == $count) | .[0]
end;

View file

@ -0,0 +1,3 @@
[1,2,3,1,2,1] | mode # => 1
[1,2,3,1,2,1,2] | mode # => 1 2
[1.1, 1.2, 1.3, 1.1, 1.2, 1.1] | mode) # => 1.1