12 Jan
2012
12 Jan
'12
3:37 p.m.
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@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.
...