Hi,
Both variants of the strict zipWith solved the gibs problem I posed:
gibs = 1 : 1 : f gibs (tail gibs)
where f (x:xs) (y:ys) = z `seq` z : f xs ys
where z = min (x + y) 10
by Simon MArlow
and
zipWith' f (x:xs) (y:ys) = let z = f x y
Axel,
...
However, they do not directly solve my problem in the bigger program which
still has the same linearly growing memory requirement. The problem seems to be
very, very hard to find. I suspect it is related to lazyness as in the gibs
example, but I just cannot put my finger on the code that
On 30 January 2005 17:09, Ben Rudiak-Gould wrote:
Axel Jantsch wrote:
Consider:
gibs = 1 : 1 : (zipWith f gibs (tail gibs))
where f x y = min (x + y) 10
[...] how can I force the garbage collector to reclaim the
memory of the head of the list after I have processed it,
Hi,
How can I get constant space behaviour for lazy, recursive streams?
Consider:
gibs = 1 : 1 : (zipWith f gibs (tail gibs))
where f x y = min (x + y) 10
This is derived from the fibs text book example, modified to bound the
memory requirement for each list element.
Evaluating gibs
Axel Jantsch wrote:
Consider:
gibs = 1 : 1 : (zipWith f gibs (tail gibs))
where f x y = min (x + y) 10
[...] how can I force the garbage collector to reclaim the
memory of the head of the list after I have processed it, since I will
never ever reference it again?
There's no entirely
Ben Rudiak-Gould writes:
Axel Jantsch wrote:
gibs = 1 : 1 : (zipWith f gibs (tail gibs))
where f x y = min (x + y) 10
[...] how can I force the garbage collector to reclaim the
memory of the head of the list after I have processed it, since I will
never ever reference it again?
On Sunday 30 Jan 2005 4:00 pm, Axel Jantsch wrote:
Hi,
How can I get constant space behaviour for lazy, recursive streams?
Consider:
gibs = 1 : 1 : (zipWith f gibs (tail gibs))
where f x y = min (x + y) 10
This is derived from the fibs text book example, modified to bound the