Logo

Programming-Idioms

History of Idiom 7 > diff from v29 to v30

Edit summary for version 30 by :

Version 29

2015-09-04, 11:38:56

Version 30

2015-10-27, 03:02:18

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
WithIndex =
  lists:zip(lists:seq(1, length(Items)), Items),
io:format("~p~n", [WithIndex]).
Doc URL
http://erldocs.com/current/stdlib/lists.html?i=0&search=lists:zip#zip/2
Demo URL
http://tryerl.seriyps.ru/#id=2ef3