4) (+) x ((*) y (r - (*) s t)) where x=4; y=5; r=2; s=3; t=6 x + y * (r - s*t) where x=4; y=5; r=2; s=3; t=6 5) (+2) ((*) ((*3) x) (y - ((+1) z))) where x=4; y=5; z=6 2 + 3 * x * (y - (1 + z)) where x=4; y=5; z=6 7) shorter :: [a] -> [b] -> Bool shorter x y = length x < length y What is interesting is that Haskell realizes that the two lists do not need to be of the same type. The shorter function doesn't look inside of either list, so Haskell types the function so that the two lists can be of different types. 11) [ x^2 | x <- [1..20], even x ] [ (2*x)^2 | x <- [1..10] ] [ 3*x | x <- [2, 4..20] ] [ 6*x | x <- [1..10] ] [ x+y | x <- [0, 6..20] , y <- [0, 3] ] [0, 3..21] [ x+y | x <- [0, 3..10], y <- [1..3] ] [1..12] [ (x,y) | x <- [1..4], y <- [4, 3..1] ] [ (x,4-y)| x <- [1..4], y <- [0..3] ] [ (x,y)| x <- [1..5], y <- [1..5], y<=x ] [ (x,y)| x <- [1..5], y <- [1..x] ] [ (x,y) | x <- [1..5], y <- [0..6], abs(x-y)<2 ] [ (x,y) | x <- [1..5], y <- [x-1..x+1] ] [ (x,y) | x <- [1..4], y <- [x, x-1..0] ] [ (x,x-y) | x <- [1..4], y <- [0..x] ] 13) (([]:[]):[]):[] (([]:[]):[]) : (([]:[]):[]) : [] [ [[[]]], [[[]]] ] 14) ex14 :: [a] -> (a,[a]) ex14 x = (head x, tail x) 15) f = (+1) g = (+) --h1 x y = f g x y h2 x y = f (g x y) --h3 x y = f (g x) y h4 x y = g (f x) y --h5 x y = g f x y --h6 x y = g (f x y) h7 x y = g x (f y) h8 x y = (g x) (f y) 16) exercise16 :: (a,b) -> (c,a) -> [a] exercise16 (u,v) (x,y) = [u, y] 17) exercise17 :: (a,b) -> (b,a) -> ([a],[b]) exercise17 (u,v) (x,y) = ([u, y], [v, x]) 18) ex18 :: (Int -> Int) -> Int -> Int ex18 f x = f x ex18 succ 6 ex18 (+2) 6 ex18 (*3) 6 19) f1 x y z = (x, y : z : []) f2 x = x 'a' f3 x = x (0::Int) --f4 x = x x f5 x = "what?" 20) ex20 :: Ord a => [a] -> a -> [a] ex20 x n = [m | m <- x, m > n] 21) First, figre out the function's type. Main> :t ex21 ex21 :: [Char] -> [Char] The function maps strings to strings. 23) [ [d1,d0] | d1 <- d, d0 <- d ] where d = "0123456789abcdef"