Loops/Nested: Difference between revisions
Content added Content deleted
(Added zkl) |
|||
Line 2,169: | Line 2,169: | ||
Nest(Array); |
Nest(Array); |
||
]</lang> |
]</lang> |
||
=={{header|zkl}}== |
|||
Using nested lists to simulate a 5x5 array. No breakbreak so an exception is used to long jump out of the loop (just 'cause, a state var could also be used). |
|||
<lang zkl>const N=5; |
|||
var rows=(0).pump(N,List, (0).pump.fp(N,List,(1).random.fpM("1-",21)) ); |
|||
try{ |
|||
foreach r in (N){ |
|||
foreach c in (N){ |
|||
x:=rows[r][c]; x.print(","); |
|||
if (x==20) { println("Found it!"); throw(Exception.Generic); } |
|||
} |
|||
} |
|||
println("Not found"); |
|||
}catch(Generic){}</lang> |
|||
{{out}} |
|||
<pre> |
|||
14,13,17,11,11,3,15,20,Found it! |
|||
3,2,10,14,10,2,2,15,2,13,11,5,12,4,17,8,10,5,14,11,10,14,11,4,1,Not found |
|||
</pre> |
|||
=={{header|ZX Spectrum Basic}}== |
=={{header|ZX Spectrum Basic}}== |