Logo

Programming-Idioms

History of Idiom 7 > diff from v28 to v29

Edit summary for version 29 by :

Version 28

2015-09-03, 13:13:42

Version 29

2015-09-04, 11:38:56

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Code
items
|> Enum.with_index
|> Enum.each(fn({x, i}) ->
  IO.puts("#{i} => #{x}")
end)
Doc URL
http://elixir-lang.org/docs/v1.0/elixir/Enum.html#with_index/1
Demo URL
http://play.elixirbyexample.com/s/f971142f9a