Ⅰ
(1)
foo [] = 0
foo (x:xs) = (if x `mod` 3 == 0 then x else 0) + foo xs
(2)
bar n = [ (i,j) | i <- [2..n-1], j <- [i+1..n], gcd i j == 1]
Ⅱ
(1)
(λf g x. f x (g x)) (λx y. x) (λx z. z)
→ (λg x. (λx y. x) x (g x)) (λx z. z)
→ λx. (λx y. x) x ((λx z. z) x)
→ λx. (λy. x) ((λx z. z) x)
→ λx. x
(2)
(λx. f x) ((λp. p (λx y. x)) ((λx y f. f x y) x x))
→ f ((λp. p (λx y. x)) ((λx y f. f x y) x x))
→ f ((λx y f. f x y) x x (λx y. x))
→ f ((λy f. f x y) x (λx y. x))
→ f ((λf. f x x) (λx y. x))
→ f ((λx y. x) x x)
→ f ((λy. x) x)
→ f x
Ⅲ
(1) -27
(2) [(1,2),(1,3),(1,4),(2,3),(2,4),(3,2),(3,4)]