Re: [Haskell-cafe] Retaining functions in memory

2011-07-27 Thread Ryan Ingram
Use memoization. Here's an example: cabal-install MemoTrie import Data.MemoTrie fib_fix :: (Integer -> Integer) -> Integer -> Integer fib_fix _ n | n < 0 = error "invalid input" fib_fix _ 0 = 1 fib_fix _ 1 = 1 fib_fix rec n = rec (n-1) + rec (n-2) -- 'tie the knot' on a recusrive function fun

Re: [Haskell-cafe] Retaining functions in memory

2011-07-26 Thread Simon Hengel
> I was looking for a way to retain the values of a specific function in > memory. Is there some way to do this. Maybe this helps: http://www.haskell.org/haskellwiki/Memoization I haven't read through it, though.. Cheers, Simon ___ Haskell-Cafe mailin

Re: [Haskell-cafe] Retaining functions in memory

2011-07-26 Thread Vo Minh Thu
2011/7/26 Siddhartha Gadgil : >       I have been making programs for mathematical applications > (low-dimensional topology) in Haskell, which I find a delight to code > in. However, the execution is slow, and this seems to be because > recursively defined functions seem to be recomputed. For examp

[Haskell-cafe] Retaining functions in memory

2011-07-26 Thread Siddhartha Gadgil
      I have been making programs for mathematical applications (low-dimensional topology) in Haskell, which I find a delight to code in. However, the execution is slow, and this seems to be because recursively defined functions seem to be recomputed. For example f(100) needs f(15) which needs f(7)