[Haskell-cafe] Something like scan1

Henning Thielemann lemming at henning-thielemann.de
Wed Jun 18 10:30:05 EDT 2008


On Wed, 18 Jun 2008, Achim Schneider wrote:

> Is there a generalisation of scan1, such that eg.
>
> foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...]
>
> ?

What is the (1,2) for? I could think of


foo f = List.unfoldr (\ xt@(x:xs) -> Just (x, xs ++ [f xt]))

foo sum [0,1]  =  [0,1,1,2,3,5,8,13,21,34,...


More information about the Haskell-Cafe mailing list