Created
February 6, 2015 12:37
-
-
Save joseanpg/40d78ef29baffa6092d3 to your computer and use it in GitHub Desktop.
Y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Mu a = In (Mu a -> a) | |
out :: Mu a -> (Mu a -> a) | |
out (In f) = f | |
omega = \f->(out f) f | |
psi = \h -> \f-> h ((out f) f) | |
yfix = \i-> omega (In (psi i)) | |
factorial = yfix (\g-> \n->if n < 2 then 1 else n*( g (n-1))) | |
{- | |
fix f = fixH (In fixH) | |
where | |
{-# NOINLINE fixH #-} | |
fixH x = f ((out x) x) | |
alpha = \f n-> if (n<2) then 1 else n * ((out f) f (n-1)) | |
omega::(Mu a->a) -> a | |
omega = \f-> out f f | |
aux = \f n->if (n < 2) then 1 else n * f (n-1) | |
factorial = fix $ \f n->if (n < 2) then 1 else n * f (n-1) | |
main = print (factorial 4) | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment