Loops/Nested: Difference between revisions
Content added Content deleted
m (Omit from: PL/0, Tiny BASIC.) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 559: | Line 559: | ||
bx lr |
bx lr |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Arturo}}== |
|||
<syntaxhighlight lang="arturo">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</syntaxhighlight> |
|||
{{out}} |
|||
<pre> 4, 12, 12, 17, 7, 13, 14, 10, 14, 9, |
|||
17, 12, 16, 10, 11, 13, 8, 13, 17, 3, |
|||
6, 17, 3, 18, 2, 16, 7, 9, 19, 9, |
|||
19, 11, 11, 14, 5, 14, 18, 17, 19, 15, |
|||
17, 16, 8, 3, 14, 17, 5, 6, 8, 1, |
|||
8, 4, 9, 10, 16, 16, 4, 15, 10, 18, |
|||
5, 8, 15, 19, 7, 8, 2, 6, 10, 8, |
|||
4, 17, 15, 18, 14, 2, 20</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |