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,7 @@
# The input is used to initialize the elements of the
# multi-dimensional array:
def multiarray(d):
. as $in
| if (d|length) == 1 then [range(0;d[0]) | $in]
else multiarray(d[1:]) | multiarray( d[0:1] )
end;

View file

@ -0,0 +1 @@
def ary: 0 | multiarray( [5, 4, 3, 2] );

View file

@ -0,0 +1 @@
ary | .[4][3][2][1]

View file

@ -0,0 +1 @@
ary | getpath( [4,3,2,1])

View file

@ -0,0 +1 @@
def ix: [4,3,2,1];

View file

@ -0,0 +1,5 @@
ary | setpath(ix; 100) | getpath(ix)
#=> 100
ary | setpath(ix; 100) | .[4][3][2][1]
#=> 100

View file

@ -0,0 +1,13 @@
def dimensions:
def same(f):
if length == 0 then true
else (.[0]|f) as $first | reduce .[] as $i (true; if . then ($i|f) == $first else . end)
end;
if type == "array"
then if length == 0 then [0]
elif same( dimensions ) then [length] + (.[0]|dimensions)
else null
end
else []
end;

View file

@ -0,0 +1,2 @@
ary | dimensions
#=> [5,4,3,2]