[Haskell-beginners] Is there an "unscan" function?
Stephen Tetley
stephen.tetley at gmail.com
Thu Jan 12 08:37:15 CET 2012
Direct recursion is almost always clearer if you are traversing the
list at a "different speed". The usual list functionals (map, filter,
folds) are all speed 1 - traversing one element at a time. Here we
want pairwise traversal:
unscan :: (a -> a -> b) -> [a] -> [b]
unscan f (a:b:bs) = f a b : unscan f b bs
unscan _ _ = []
On 12 January 2012 06:41, Kyle Murphy <orclev at gmail.com> wrote:
> 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.
>
...
More information about the Beginners
mailing list