Re: [Haskell-cafe] Memoization-question

2008-12-16 Thread Mattias Bengtsson
On Fri, 2008-12-12 at 15:47 +0100, Bertram Felgenhauer wrote: GHC does opportunistic CSE, when optimizations are enabled. [...] I see. Thank you! Mattias ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Memoization-question

2008-12-12 Thread Bertram Felgenhauer
Mattias Bengtsson wrote: The program below computes (f 27) almost instantly but if i replace the definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it takes around 12s to terminate. I realize this is because the original version caches results and only has to calculate, for

[Haskell-cafe] Memoization-question

2008-12-11 Thread Mattias Bengtsson
The program below computes (f 27) almost instantly but if i replace the definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it takes around 12s to terminate. I realize this is because the original version caches results and only has to calculate, for example, (f 25) once instead of (i

Re: [Haskell-cafe] Memoization-question

2008-12-11 Thread Donnie Jones
Hello Mattias, I think you will find this thread from the haskell-cafe mailing list quite helpful. Re: [Haskell-cafe] Memoization http://www.mail-archive.com/haskell-cafe@haskell.org/msg09924.html Also, the Haskell wiki contains comments about techniques for memoization along with references

Re: [Haskell-cafe] Memoization-question

2008-12-11 Thread Daniel Fischer
Am Donnerstag, 11. Dezember 2008 16:18 schrieb Mattias Bengtsson: The program below computes (f 27) almost instantly but if i replace the definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it takes around 12s to terminate. I realize this is because the original version caches

Re[2]: [Haskell-cafe] Memoization-question

2008-12-11 Thread Bulat Ziganshin
Hello Daniel, Thursday, December 11, 2008, 11:09:46 PM, you wrote: you is almost right. but ghc don't share results of function calls despite their type. it just assumes that value of any type may use a lot of memory even if this type is trivial :) example when automatic sharing is very bad

Re: [Haskell-cafe] Memoization-question

2008-12-11 Thread Daniel Fischer
Am Donnerstag, 11. Dezember 2008 21:11 schrieb Bulat Ziganshin: Hello Daniel, Thursday, December 11, 2008, 11:09:46 PM, you wrote: you is almost right. but ghc don't share results of function calls despite their type. it just assumes that value of any type may use a lot of memory even if

Re[2]: [Haskell-cafe] Memoization-question

2008-12-11 Thread Bulat Ziganshin
Hello Daniel, Thursday, December 11, 2008, 11:49:40 PM, you wrote: sorry fo r noise, it seems that i know ghc worse than you Am Donnerstag, 11. Dezember 2008 21:11 schrieb Bulat Ziganshin: Hello Daniel, Thursday, December 11, 2008, 11:09:46 PM, you wrote: you is almost right. but ghc

Re: [Haskell-cafe] Memoization-question

2008-12-11 Thread Daniel Fischer
Am Donnerstag, 11. Dezember 2008 21:56 schrieb Bulat Ziganshin: Hello Daniel, Thursday, December 11, 2008, 11:49:40 PM, you wrote: sorry for noise, it seems that i know ghc worse than you If only that were true. I just know that GHC's optimiser can do some rather impressive stuff when given