Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
@ -0,0 +1 @@
|
|||
def ary: 0 | multiarray( [5, 4, 3, 2] );
|
||||
|
|
@ -0,0 +1 @@
|
|||
ary | .[4][3][2][1]
|
||||
|
|
@ -0,0 +1 @@
|
|||
ary | getpath( [4,3,2,1])
|
||||
|
|
@ -0,0 +1 @@
|
|||
def ix: [4,3,2,1];
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
ary | setpath(ix; 100) | getpath(ix)
|
||||
#=> 100
|
||||
|
||||
ary | setpath(ix; 100) | .[4][3][2][1]
|
||||
#=> 100
|
||||
13
Task/Multi-dimensional-array/Jq/multi-dimensional-array-7.jq
Normal file
13
Task/Multi-dimensional-array/Jq/multi-dimensional-array-7.jq
Normal 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;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
ary | dimensions
|
||||
#=> [5,4,3,2]
|
||||
Loading…
Add table
Add a link
Reference in a new issue