-- Fibinachi using fixpoint and lazy
lazyFib :: Int -> Lazy Int
lazyFib x
| x < 2 = defer \_ -> 1
| otherwise = defer \_ -> (force $ (lazyFib (x-1))) + (force $ (lazyFib (x-2)))
fixFib :: (Int -> Int)
fixFib = fix (\rec n -> if n < 2 then 1 else rec(n-1) + rec (n-2))
runFixFib :: Int -> Int
runFixFib m = fixFib m
Created
June 22, 2017 20:49
-
-
Save dgendill/a7e996c57449d92e56e62ce522ab1a3a to your computer and use it in GitHub Desktop.
Using Purescript Lazy Fixpoint and Lazy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment