Skip to content

Instantly share code, notes, and snippets.

@joseanpg
Created February 6, 2015 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseanpg/40d78ef29baffa6092d3 to your computer and use it in GitHub Desktop.
Save joseanpg/40d78ef29baffa6092d3 to your computer and use it in GitHub Desktop.
Y
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