File: test1.hs

package info (click to toggle)
haskell-memoize 1.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 108 kB
  • sloc: haskell: 401; makefile: 2
file content (8 lines) | stat: -rw-r--r-- 296 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
import Data.Function.Memoize
import Data.Function (fix) -- for comparison

main = print $
  let fib :: Integer -> Integer
      fib = memoFix $ \ f -> \ x -> if x < 2 then x else f (x-1) + f (x-2)
      -- and it would take much longer with  fib = fix $ \ f -> ...
  in  take 100 $ map fib [0..]