[Haskell-cafe] Why does this blow the stack?

Justin Bailey jgbailey at gmail.com
Fri Dec 21 12:51:46 EST 2007


On Dec 21, 2007 9:48 AM, Brad Larsen <brad.larsen at gmail.com> wrote:
> I'm curious as well.  My first thought was to try the (!!) operator.
> Typing
>
>    Prelude> [1..] !! 550000
>
> overflows the stack on my computer, as does dropTest 550000.

I think its [1..] which is building up the unevaluated thunk. Using
this definition of dropTest does not blow the stack:

  dropTest n = head . drop n $ repeat 1

Justin


More information about the Haskell-Cafe mailing list