noritsuguの日記

2009-04-14``Algorithms'' (39) Exercise 2.10

Prelude> map fst [(1, 2), (3, 8), (0, 6), (3, 1)]
[1,3,0,3]
Prelude> let l     = [6,9,8,3,10]
Prelude> let f x y = (x+y) `div` 2
Prelude> (foldr f 0 l, foldl f 0 l)
(6,7)
Prelude> foldr (++) [] [[1, 2, 3], [4, 5, 6], [], [7]]
[1,2,3,4,5,6,7]
トラックバック - http://haskell.g.hatena.ne.jp/noritsugu/20090414