Programming-Idioms

History of Idiom 2 > diff from v87 to v88

Edit summary for version 88 :
[Elixir] Using function composing is more coomon in elixir

Version 87

2019-09-26, 21:52:15

Version 88

2019-09-26, 21:55:20

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Code
for _ <- 1..10, do: IO.puts "hello"
Code
1..10 |> Enum.each(fn _ -> IO.puts "hello" end)
Comments bubble
The pipe operator is very common in elixir and is used to chain function calls
Doc URL
http://elixir-lang.org/docs/stable/elixir/Kernel.SpecialForms.html#for/1
Doc URL
https://hexdocs.pm/elixir/1.0.5/Enum.html#each/2
Demo URL
http://play.elixirbyexample.com/s/44301cf4c3