Haskell学习笔记--scanl/scanr
类似foldl/flodr
但是将每一步都记录下来,保存为list
scanl :: (b -> a -> b) -> b -> [a] -> [b]
scanr :: (a -> b -> b) -> b -> [a] -> [b]
eg.
scanl (+) 0 [1,2,3]
--[0,1,3,6]
scanr (+) 0 [1,2,3]
--[6,5,3,0]