[PRL] laziness

Joe Marshall prunesquallor at comcast.net
Wed Jun 23 06:35:32 EDT 2004


Johan <johan at ccs.neu.edu> writes:

> However, there is (IMHO) a a big win in clarity / expressiveness. "if"
> becomes a function, not syntax...
>
> Or my all-time-favotite: LU decomposition. See pages 6 /7 of
> http://www.dcs.gla.ac.uk/fp/workshops/fpw97/EllmenreichLeng.ps

You may also enjoy this:
  Lazy Dynamic-Programming can be Eager.
    L. Allison,
    Department of Computer Science,
    Monash University,
    Australia 3168.

  http://www.csse.monash.edu.au/~lloyd/tildeStrings/Alignment/92.IPL.html
 

> try the following on for size:
>
> foldl f acc []  = acc
> foldl f acc (hd:tl) = foldl f (f hd acc) tl
>
> nice and tail-recursive. however
>
> foldl (+) 0 [0 .. 10000000]
>
> fails to terminate: runs out of memory.

I believe that may be an obscure bug.  The same thing happens when you
use streams in Scheme if you are not careful about how storage is
maintained.

-- 
~jrm




More information about the PRL mailing list