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


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

(1) [1,4,9,16,25,36,49]
(2) [(1,4),(1,6),(2,2),(2,6),(3,2),(3,4)]