
29 Aug
2007
29 Aug
'07
5:06 p.m.
Hi Alexteslin,
I just came across with this question on the exam and can not think of implementing it.
mapPair :: (a -> a -> a) -> [a] -> [a]
such that mapPairs f [x1, x2, x3, x4...] = [f x1 x2, f x3 x4,...]
I would implement this using direct recursion. As a starting point, the standard definition of map is: map f [] = [] map f (x:xs) = f x : map f xs You should be able to start at this and modify it to give the behaviour you require. If you want further hints, you might want to try the Haskell IRC Channel, which is good for these kind of questions. http://www.haskell.org/haskellwiki/IRC_channel Thanks Neil