
3 Feb
2009
3 Feb
'09
10:26 a.m.
On Feb 3, 2009, at 10:15 AM, Dave Bayer wrote:
The following takes forever, but it doesn't consume memory:
Prelude> :m Data.List Prelude Data.List> genericIndex (zip (cycle [1..3]) (cycle [1..4])) (1000^1000)
So zip is doing something smart here with cyclic lists.
No, I just wasn't saving the head. This burns memory:
Prelude Data.List> let a = zip (cycle [1..3]) (cycle [1..4]) Prelude Data.List> head a (1,1) Prelude Data.List> genericIndex a (1000^1000) <interactive>: memory allocation failed (requested 2097152 bytes)