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
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
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 hav
On Sunday 30 Jan 2005 4:00 pm, Axel Jantsch wrote:
> Main> nth 100 fibs
> 10
> (2818 reductions, 3730 cells, 1 garbage collection)
>
> Main> nth 200 fibs
> 10
> (5618 reductions, 7430 cells, 1 garbage collection)
>
> which suggests linear space behaviour.
Hmm, not sure exactly what Hugs is
On Sunday 30 Jan 2005 7:40 pm, Adrian Hey wrote:
> 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
> >
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 bou
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?
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 entir