Hi

> mapPairs :: (a -> a -> a) -> [a] -> [a]
> mapPairs f [x] = [x]
> mapPairs f [] = []
> mapPairs f (x:xs) = f x (head xs) : mapPairs f (tail xs)

It looks like it works, but you can get a better version by changing
the last line:

mapPairs f (x:y:zs) = ... - left as an exercise, but no need for head or tail.

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to