RosettaCodeData/Task/Loops-Nested/Jq/loops-nested-1.jq
2017-09-25 22:28:19 +02:00

11 lines
335 B
Text

# Given an m x n matrix,
# produce a stream of the matrix elements (taken row-wise)
# up to but excluding the first occurrence of $max
def stream($max):
. as $matrix
| length as $m
| (.[0] | length) as $n
| label $ok
| {i: range(0;$m), j: range(0;$n)}
| $matrix[.i][.j] as $m
| if $m == $max then break $ok else $m end ;