Re: [Haskell-cafe] Memoization/call-by-need

2010-09-20 Thread Henning Thielemann
Alex Rozenshteyn schrieb: > I feel that there is something that I don't understand completely: I > have been told that Haskell does not memoize function call, e.g. >> slowFib 50 > will run just as slowly each time it is called. However, I have read > that Haskell has call-by-need semantics, which

Re: [Haskell-cafe] Memoization/call-by-need

2010-09-16 Thread Román González
Alex, Maybe this pdf can enlighten you a little bit about memoization and lazy evaluation in Haskell => http://www.cs.uu.nl/wiki/pub/USCS2010/CourseMaterials/A5-memo-slides-english.pdf Cheers. Roman.- I feel that there is something that I don't understand completely: I have > been told that H

Re: [Haskell-cafe] Memoization/call-by-need

2010-09-16 Thread Ketil Malde
Alex Rozenshteyn writes: > I understand that >> fib50 = slowFib 50 > will take a while to run the first time but be instant each subsequent call; > does this count as memoization? I didn't see anybody else answering this in so many words, but I'd say no, since you only name one particular valu

Re: [Haskell-cafe] Memoization/call-by-need

2010-09-15 Thread wren ng thornton
On 9/15/10 10:39 PM, Conal Elliott wrote: Hi Alex, In Haskell, data structures cache, while functions do not. Exactly. What this means is that when you call (slowFib 50) Haskell does not alter slowFib in any way to track that it maps 50 to $whatever; however, it does track that that particul

Re: [Haskell-cafe] Memoization/call-by-need

2010-09-15 Thread Conal Elliott
Hi Alex, In Haskell, data structures cache, while functions do not. "Memoization" is conversion of functions into data structures (and then trivially re-wrapping as functions) so as to exploit the caching property of data structures to get caching functions. - Conal On Wed, Sep 15, 2010 at 11

Re: [Haskell-cafe] Memoization/call-by-need

2010-09-15 Thread Daniel Fischer
On Wednesday 15 September 2010 22:38:48, Tim Chevalier wrote: > On the other hand, if you wrote: > > let fib50 = slowFib 50 in >   fib50 + (slowFib 50) > > then (slowFib 50) would be evaluated twice, because there's no > principle requiring the compiler to notice that (slowFib 50) is the > same exp

Re: [Haskell-cafe] Memoization/call-by-need

2010-09-15 Thread Tim Chevalier
On 9/15/10, Alex Rozenshteyn wrote: > I feel that there is something that I don't understand completely: I have > been told that Haskell does not memoize function call, e.g. > > slowFib 50 > will run just as slowly each time it is called. However, I have read that > Haskell has call-by-need sema

[Haskell-cafe] Memoization/call-by-need

2010-09-15 Thread Alex Rozenshteyn
I feel that there is something that I don't understand completely: I have been told that Haskell does not memoize function call, e.g. > slowFib 50 will run just as slowly each time it is called. However, I have read that Haskell has call-by-need semantics, which were described as "lazy evaluation