プログラミング・パラダイム(2015 年度)テスト解答例(一部)


(1)
  foo []     = 0
  foo (x:xs) = (if x `mod` 2 == 1 then x else 0) + foo xs
(2)
  bar n = [ (i,j) | i <- [2..n], j <- [i..n], i * j <= n ]

(1) [1,2,5,14]
(2) [(2,3),(2,4),(2,5),(3,4),(4,3),(4,4),(4,5)]