Re: what is leaking?

1998-06-29 Thread Alex Ferguson
Hi Alex. If you use a different (but still lazy) definition of foldl: myFoldl f s [] = s myFoldl f s (x:xs) = f s (foldl f x xs) Unless I'm more asleep than I realise, this is just foldr, isn't it? (To wit, "fold to the right", rather than "fold to the left".) In fact, foldr is the

Re: what is leaking?

1998-06-28 Thread Marko Schuetz
From: "S. Alexander Jacobson" [EMAIL PROTECTED] Subject: Re: what is leaking? Date: Fri, 26 Jun 1998 16:38:12 -0400 () Wow! If Ralf is right, then foldl in a lazy language always generates a space leak and should be avoided in favor of strictFoldl. However, I still am not

Re: what is leaking?

1998-06-27 Thread Alastair Reid
As an aside, I think strictFoldl is not automatically paralellizable, but myFoldl may be. [...] If dreams of automatic parallelisation of lazy functional programs were pennies, I'd have $2.35. Alastair

Re: what is leaking?

1998-06-27 Thread Koen Claessen
On Fri, 26 Jun 1998, S. Alexander Jacobson wrote: | myFoldl f s [] = s | myFoldl f s (x:xs) = f s (foldl f x xs) | total = 3 + (myFoldl (+) 3 [4..10]) | total = 3 + 4 + (myFoldl (+) 4 [5..10]) The problem is parenthesis; the last expression should have been: total = 3 + (4

Re: what is leaking?

1998-06-26 Thread Ralf Hinze
When I try to execute this: result = foldl (+) 0 [1..10] main = putStr $show (result `mod` 10) Hugs gives: ERROR: Garbage collection fails to reclaim sufficient space GHC gives: Stack space overflow: current size 262152 bytes. Why would this have an error? The list should be

Re: what is leaking?

1998-06-26 Thread S. Alexander Jacobson
Wow! If Ralf is right, then foldl in a lazy language always generates a space leak and should be avoided in favor of strictFoldl. However, I still am not clear why explicity strictness is required for foldl to behave properly. In fact it seems like the problem is insufficient laziness. If