RosettaCodeData/Task/Loops-Nested/Arturo/loops-nested.arturo
2023-07-01 13:44:08 -04:00

24 lines
516 B
Text

printTable: function [tbl][
; wrapping the nested loop in a function
; allows us to use return to exit all of the loops
; since `break` only exits the inner loop
loop 0..dec size tbl 'x [
loop 0..dec size tbl\[x] 'y [
prints pad to :string tbl\[x]\[y] 2
if tbl\[x]\[y] = 20 -> return ø
prints ", "
]
print ""
]
]
a: []
loop 1..10 'x [
row: []
loop 1..10 'y [
'row ++ random 1 20
]
'a ++ @[row]
]
printTable a