Re: [Haskell] space behaviour of lazy recursive lists

2005-02-03 Thread Colin Runciman
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

Re: [Haskell] space behaviour of lazy recursive lists

2005-02-03 Thread Axel Jantsch
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

RE: [Haskell] space behaviour of lazy recursive lists

2005-02-01 Thread Simon Marlow
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

Re: [Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread Adrian Hey
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

Re: [Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread Adrian Hey
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 > >

Re: [Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread Adrian Hey
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

Re: [Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread karczma
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?

Re: [Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread Ben Rudiak-Gould
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

[Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread Axel Jantsch
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 gib