# 07.26.07

## Exercise 5.5

doubleEach :: [Int] -> [Int] doubleEach xs = map (\x -> x * 2) xs doubleEach' (x:xs) = (x * 2) : doubleEach' xs doubleEach' [] = [] pairAndOne :: [Int] -> [(Int, Int)] pairAndOne xs = zip xs (map (\x -> x + 1) xs) pairAndOne' (x:xs) = (x, x+1) : pairAndOne' xs pairAndOne' [] = [] addEachPair :: [(Int, Int)] -> [Int] addEachPair xs = map (\(a,b) -> a + b) xs addEachPair' ((a,b):xs) = (a + b) : addEachPair' xs addEachPair' [] = [] |

The Haskell School of Expression: Exercises » Exercise 9.12 said,

August 9, 2007 at 9:13 pm

[…] Instances where we can curry and convert anonymous functions to sections are easy to find, for example from Exercise 5.5: […]