--- /dev/null
+module Hw4 where
+
+-- wholemeal programming
+{- |
+
+1. fun1 :: [Integer] -> Integer
+fun1 [] = 1
+fun1 (x:xs)
+ | even x = (x - 2) * fun1 xs
+ | otherwise = fun1 xs
+
+2. fun2 :: Integer -> Integer fun2 1 = 0
+ fun2n | even n = n + fun2 (n ‘div‘ 2)
+ | otherwise = fun2 (3 * n + 1)
+Hint: For this problem you may wish to use the functions
+ iterate and takeWhile. Look them up in the Prelude
+ documentation to see what they do.
+-}
+
+fun1 :: [Integer] -> Integer
+fun1 [] = 1
+fun1 (x:xs)
+ | even x = (x - 2) * fun1 xs
+ | otherwise = fun1 xs
+
+fun1' :: [Integer] -> Integer
+fun1' = product . (map (\x -> x - 2)) . filter even
+
+fun2 :: Integer -> Integer
+fun2 1 = 0
+fun2 n | even n = n + fun2 (n `div` 2)
+ | otherwise = fun2 (3 * n + 1)
+
+fun2' :: Integer -> Integer
+fun2' n = sum $ filter even $ takeWhile (/= 1) $ iterate gen n
+ where gen x | even x = x `div` 2
+ | otherwise = 3 * x + 1