foo [] = 0 foo ((x,y):xs) | odd x && even y = x + foo xs | even x && odd y = y + foo xs | otherwise = foo xs(2)
bar n = [(x,y)| x <- [0..n], y <- [n..2*n], y - x <= n]Ⅱ
(1) [1,2,4,8]
(2) 32
(3) [(4,2),(4,3),(5,1),(5,3),(5,4),(6,1),(6,2),(6,3),(6,4),(6,5),(6,6)]