Skip to content
Snippets Groups Projects
Commit 2cd1a07b authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1999-08-04 10:07:50 by simonmar]

Add a test for a rather misguided use of the Memo library, but which
showed up a bug nevertheless :)
parent b2eced5b
No related branches found
No related tags found
No related merge requests found
#-----------------------------------------------------------------------------
# $Id: Makefile,v 1.12 1999/06/09 09:35:58 simonpj Exp $
# $Id: Makefile,v 1.13 1999/08/04 10:07:50 simonmar Exp $
TOP = ../..
include $(TOP)/mk/boilerplate.mk
......@@ -29,6 +29,9 @@ memo001_HC_OPTS = -syslib misc
# finalized properly, and stable names are GC'd etc.
memo001_RUNTEST_OPTS = +RTS -A10k -G1
memo002_HC_OPTS = -syslib misc
memo002_RUNTEST_OPTS = 20
SRC_MKDEPENDHS_OPTS += -syslib misc -syslib exts
include $(TOP)/mk/target.mk
......
module Main
where
import Memo
import System(getArgs)
main = do (arg:_) <- getArgs
mapM_ printTriple [ (i,fib i,mfib i) | i <- [10..read arg] ]
where printTriple (i,fi,mfi) = do print i
print fi
print mfi
putStrLn ""
mfib :: Integer -> Integer
mfib = memo ufib
ufib :: Integer -> Integer
ufib 0 = 1
ufib 1 = 1
ufib n = mfib (n-1) + mfib (n-2)
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment