Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue