Jump to content

Loops/Continue: Difference between revisions

Added Elixir
(Added Elixir)
Line 393:
 
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}}==
Line 400 ⟶ 418:
main() ->
for_loop(1).
for_loop(N) when N /= 5 , N <10 ->
io:format("~p, ",[N] ),
for_loop(N+1);
for_loop(N) when N >=10->
if N=:=10 ->
io:format("~p\n",[N] )
end;
for_loop(N) ->
if N=:=5 ->
io:format("~p\n",[N] ),
for_loop(N+1)
Line 421 ⟶ 439:
6, 7, 8, 9, 10
ok</pre>
 
 
=={{header|ERRE}}==
Line 1,008 ⟶ 1,025:
Though even if the continue statement does not exist,
it is possible to add it with camlp4.
 
 
=={{header|Octave}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.