Loops/Continue: Difference between revisions
Content added Content deleted
(Added Elixir) |
|||
Line 393: | Line 393: | ||
This version is more generic and can work for any given range of values. |
This version is more generic and can work for any given range of values. |
||
=={{header|Elixir}}== |
|||
<lang elixir>defmodule Loops do |
|||
def continue do |
|||
Enum.each(1..10, fn i -> |
|||
IO.write i |
|||
IO.write if rem(i,5)==0, do: "\n", else: ", " |
|||
end) |
|||
end |
|||
end |
|||
Loops.continue</lang> |
|||
{{out}} |
|||
<pre> |
|||
1, 2, 3, 4, 5 |
|||
6, 7, 8, 9, 10 |
|||
</pre> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
Line 400: | Line 418: | ||
main() -> |
main() -> |
||
for_loop(1). |
for_loop(1). |
||
for_loop(N) when N /= 5 , N <10 -> |
|||
io:format("~p, ",[N] ), |
io:format("~p, ",[N] ), |
||
for_loop(N+1); |
for_loop(N+1); |
||
for_loop(N) when N >=10-> |
for_loop(N) when N >=10-> |
||
if N=:=10 -> |
|||
io:format("~p\n",[N] ) |
io:format("~p\n",[N] ) |
||
end; |
end; |
||
for_loop(N) -> |
|||
if N=:=5 -> |
|||
io:format("~p\n",[N] ), |
io:format("~p\n",[N] ), |
||
for_loop(N+1) |
for_loop(N+1) |
||
Line 421: | Line 439: | ||
6, 7, 8, 9, 10 |
6, 7, 8, 9, 10 |
||
ok</pre> |
ok</pre> |
||
=={{header|ERRE}}== |
=={{header|ERRE}}== |
||
Line 1,008: | Line 1,025: | ||
Though even if the continue statement does not exist, |
Though even if the continue statement does not exist, |
||
it is possible to add it with camlp4. |
it is possible to add it with camlp4. |
||
=={{header|Octave}}== |
=={{header|Octave}}== |