[Haskell-beginners] Is there an "unscan" function?

David Virebayre dav.vire+haskell at gmail.com
Thu Jan 12 08:17:45 CET 2012

2012/1/12 Kyle Murphy <orclev at gmail.com>:
> I was able to build something incredibly convoluted that accomplishes what
> you want, but I'm sure there's a better way to do it.

Not sure if it's a better way.

unscan l = head l : zipWith (subtract) l (tail l)

Corrected to work for empty lists :

unscan [] = []
unscan l@(x:xs) = x :  zipWith (subtract) l xs


More information about the Beginners mailing list