[Haskell-beginners] Is there an "unscan" function?
Jeffrey Thornton
jeffreyjthornton at gmail.com
Fri Jan 13 02:43:31 CET 2012
Is "speed x" at least a somewhat universal term for the number of list
elements that get operated on per iteration? It works really well.
I was also wondering about what you just pointed out: if there's a nice way
to form (what I now know to call) speed >1 functions. Your form looks a lot
nicer than some of the stranger things I've been coming up with.
On Thu, Jan 12, 2012 at 1:37 AM, Stephen Tetley <stephen.tetley at gmail.com>wrote:
> 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 _ _ = []
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120112/de158566/attachment.htm>
More information about the Beginners
mailing list