25 lines
516 B
Text
25 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
|