
18 Dec
2012
18 Dec
'12
2:28 p.m.
Hi,
When I run this code in ghci:
reverse [1..]
I get:
<interactive>: out of memory (requested 2097152 bytes)
Can anyone explain this behaviour?
It is an infinite list you are trying to reverse. This cannot terminate. Which is the first element you would expect to see in the result? Those two will finish: reverse $ take 100 [1..] reverse [1..100] Emmanuel