Logo

Programming-Idioms

History of Idiom 7 > diff from v46 to v47

Edit summary for version 47 by :
[Haskell] Shorter, more idiomatic, less duplication

Version 46

2016-02-16, 21:21:42

Version 47

2016-02-17, 11:50:39

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
sequence_ [print (i,x) | (i,x) <- zip [0..] items]
Code
mapM_ print (zip [0..] items)