Logo

Programming-Idioms

History of Idiom 143 > diff from v9 to v10

Edit summary for version 10 by Algorhythmus:
New Haskell implementation by user [Algorhythmus]

Version 9

2017-08-21, 19:30:41

Version 10

2017-09-12, 15:27:39

Idiom #143 Iterate alternatively over two lists

Iterate alternatively over the elements of the list items1 and items2. For each iteration, print the element.

Idiom #143 Iterate alternatively over two lists

Iterate alternatively over the elements of the list items1 and items2. For each iteration, print the element.

Extra Keywords
parallel
Extra Keywords
parallel
Code
interweave :: [a] -> [a] -> [a]   -- optional signature
interweave [] ys = ys
interweave xs [] = xs
interweave (x:xs) (y:ys) = x : y : interweave xs ys

main = mapM_ print $ interweave items1 items2
Comments bubble
$ is the function application operator of Haskell to eliminate annoying parentheses.

E.g., f $ g x y z == f (g x y z)