Jump to content

Loops/Nested: Difference between revisions

Added Tailspin solution
(Added Commodore BASIC)
(Added Tailspin solution)
Line 3,701:
done
</pre>
 
=={{header|Tailspin}}==
In Tailspin you break processing by simply not sending a value on in the chain.
<lang tailspin>
sink find20
def a: $;
1 -> #
when <..$a::length> do def i: $;
'$#10;' -> !OUT::write
1 -> \(
when <$a($i)::length~..> do $i + 1 !
otherwise def j: $;
def val: $a($i;$j);
' $val;' -> !OUT::write
$val -> \(<~=20> $j + 1 ! \) -> #
\) -> #
end find20
 
[1..10 -> [1..10 -> 20 -> SYS::randomInt -> $ + 1]] -> !find20
</lang>
{{out}}
<pre>
 
3 4 2 10 10 10 2 16 9 14
10 2 8 7 19 13 9 9 2 6
5 8 11 18 14 5 3 1 7 19
18 18 16 3 1 19 19 8 6 6
18 9 17 16 13 16 12 15 4 2
12 20</pre>
 
=={{header|Tcl}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.