zip' :: [a] -> [b] -> [(a, b)] zip' [] y = [] zip' (x:xs) [] = [] zip' (x:xs) (y:ys) = (x, y) : zip' xs ys reverse' :: [a] -> [a] reverse' [] = [] reverse' (x:xs) = reverse' xs ++ [x] -- reverse'' :: [a] -> [a] -- reverse'' [] = [] -- reverse'' (x:xs) = last xs ++ reverseH :: [a] -> [a] -> [a] reverseH [] ys = ys reverseH (x:xs) ys = reverseH xs (x:ys) reverse'' :: [a] -> [a] reverse'' l = reverseH l [] -- Anonymous functions -- '\' is for \lambda, coming from lambda calculus -- \ x -> x + 1 -- \ x -> (\ y -> x + y) -- \ x y -> x + y -- Higher order functions map' :: (a -> b) -> [a] -> [b] map' f [] = [] map' f (x:xs) = f x : map' f xs -- filter filter' :: (a -> Bool) -> [a] -> [a] filter' f [] = [] filter' f (x:xs) = if f x then x : filter' f xs else filter' f xs zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c] zipWith' f [] y = [] zipWith' f (x:xs) [] = [] zipWith' f (x:xs) (y:ys) = f x y : zipWith' f xs ys