functional programming - Iterating along 2 lists at the same time in haskell (without resorting to zip) -


i have 2 lists:

[[1,2],[4,5]] 

and

[0, 3] 

and i'd turn into

[[0,1,2],[3,4,5]] 

i've created function that:

myfun xxs xs = map (\x -> (fst x):(snd x)) (zip xs xxs) 

and works. still left wondering whether there might exist better way accomplish without using zip. there any?

basically want iterate along 2 lists @ same time, can't think of way in haskell without resorting zip.

thanks

use zipwith. example:

zipwith (:) [0,3] [[1,2],[4,5]] 

gives:

[[0,1,2],[3,4,5]] 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -