[Haskell-cafe] iterative algorithms: how to do it in Haskell?

ajb at spamcop.net ajb at spamcop.net
Thu Aug 17 01:23:19 EDT 2006


G'day all.

Quoting Chris Kuklewicz <haskell at list.mightyreason.com>:

> The compiler may not deforest that list, so creating the list may be a small
> overhead of this method.

And in return, you get:

    - Code that is smaller than the imperative version, AND
    - a reusable function, making the next incarnation of
      an algorithm like this even shorter.

For most interesting cases, the cost of f and goOn will surely dominate
anyway.

> Note that "f x" should be "f a" above.

Yes, you're right.  I abstracted out "f" after testing and before
posting.

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list