[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Haskell and "memoization"

Subject: Re: [Haskell-cafe] Haskell and "memoization"
From: Gregory Crosswhite
Date: Tue, 15 Dec 2009 20:47:20 -0800
Hmm, you raise an 
On Dec 15, 2009, at 8:28 PM, Daniel Fischer wrote:

> Am Mittwoch 16 Dezember 2009 05:08:39 schrieb Gregory Crosswhite:
> 
> Not even then, necessarily. And it's not always a good idea.
> 
> f k = [1 .. 20^k]
> 

You raise a really good point here.  One can force sharing, as I understand it, 
by using a let clause:

n =
        let xs = f 20
        in length (xs ++ xs)

If I understand correctly, this should cause xs to be first evaluated, and then 
cached until the full length is computed, which in this case is obviously 
undesirable behavior.

Cheers,
Greg

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>