SOE ex.9.11


f1 f g xs = map f (map g xs) -- each element will be f(g(x))
f2 f g xs = map (f.g) xs


f3 xs = map (\x -> (x+1)/2) xs
f4 xs = map ((/2).(+1)) xs
f5 xs = map (/2) (map (+1) xs)


----- test -----
main = do
  putStrLn $ show $ f1 (*3) (+2) [1..10]
  putStrLn $ show $ f2 (*3) (+2) [1..10]
  putStrLn $ show $ f3 [1..10]
  putStrLn $ show $ f4 [1..10]
  putStrLn $ show $ f5 [1..10]

Leave a Reply