Loops/Nested: Difference between revisions

Added Elixir
m (→‎{{header|Pascal}}: Blanks suppressed)
(Added Elixir)
Line 538:
}
println("done.")</lang>
 
=={{header|Elixir}}==
<lang elixir>defmodule Loops do
def nested do
:random.seed(:os.timestamp)
list = Enum.shuffle(1..20) |> Enum.chunk(5)
IO.inspect list, char_lists: :as_lists
try do
nested(list)
catch
:find -> IO.puts "done"
end
end
def nested(list) do
Enum.each(list, fn row ->
Enum.each(row, fn x ->
IO.write "#{x} "
if x == 20, do: throw(:find)
end)
IO.puts ""
end)
end
end
 
Loops.nested</lang>
 
{{out|Sample output}}
<pre>
[[3, 11, 4, 15, 18], [8, 7, 12, 17, 9], [6, 20, 14, 1, 16], [2, 5, 10, 19, 13]]
3 11 4 15 18
8 7 12 17 9
6 20 done
</pre>
 
=={{header|Erlang}}==
Line 563 ⟶ 597:
random_array( Size ) -> [random:uniform(Size) || _X <- lists:seq(1, Size)].
</lang>
 
 
=={{header|ERRE}}==
Anonymous user