Hi all,

If you compile and run this:

    main = do
      putStrLn $ show $ take (last [0..]) [0..]

or simply run:

    take (last [0..]) [0..]

in ghci, it first hang for about one minute and then starts to generate an
infinite list. I was expecting "last [0..]" to never produce a value and the
"take" function to never take from the [0..] list.

I found that line of code in a friend's "Skype Message", lauched it in ghci
and forgot it. When I came back to my ghci window a couple minutes later it
was listing numbers, which was really unexpected.

If I just run "last [0..]" it doesn't return a value and my computer will
quickly start to paginate to death. Am I missing something? Some laziness
magic? Rewrite rules?

Thanks,

Olivier.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to