[Haskell-cafe] Newbie question: Where is StackOverflow on the
derek.a.elkins at gmail.com
Sat Aug 18 14:54:27 EDT 2007
On Sat, 2007-08-18 at 20:35 +0200, Peter Verswyvelen wrote:
> When reading an article about tail recursion
> html) I came across the follow statements:
> "If you can write a non-recursive function that uses the colon syntax it is
> probably better than a tail recursive one that doesn't. This is because
> Haskell's lazy evaluation enabled you to use the non-tail recursive version
> on an infinite stream without getting a stack overflow. "
> ""Unfortunately", laziness "gets in the way". While transforming
> non-tail-recursive code to a tail-recursive form is important and useful for
> functional programming in general, dealing with laziness requires a little
> more care, and often "non-tail-recursive" versions are preferrable. flatten
> is an example of this, the first version is better in many ways. While I
> don't believe it happens in this case, oftentimes naively writing code
> "tail-recursively" in Haskell will actually -make- it overflow the stack.
> Another (actual) benefit of the first version of flatten is that it will
> work on infinite lists. http://www.haskell.org/hawiki/StackOverflow gives a
> simple example and some explanation."
That page was migrated here:
More information about the Haskell-Cafe