Logo

Programming-Idioms

History of Idiom 7 > diff from v80 to v81

Edit summary for version 81 by programming-idioms.org:
[Elixir] Dead link: play.elixirbyexample.com has been down for a while

Version 80

2019-10-09, 22:39:34

Version 81

2019-10-14, 12:21:23

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

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