Created
May 17, 2016 12:05
-
-
Save useronym/7dc5a0222e7e82c2dd1e0a1d92f8703b to your computer and use it in GitHub Desktop.
This file contains 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
module Combinators where | |
open import Data.Nat.Base | |
data Mu (A : Set) : Set where | |
roll : A → Mu A | |
unroll : ∀ {A : Set} → Mu A → A | |
unroll (roll a) = a | |
Y : ∀ {A : Set} → (A → A) → A | |
Y = λ f → (λ x → f (unroll x x)) (roll (λ x → f (unroll x x))) | |
fac : (ℕ → ℕ) → ℕ → ℕ | |
fac f zero = suc zero | |
fac f n = n * f (pred n) | |
-- Y fac 1 → 1 | |
-- Y fac 2 → _24 fac (_26 fac (roll (λ x → fac (_24 fac x)))) 0 + 0 + (_24 fac (_26 fac (roll (λ x → fac (_24 fac x)))) 0 + 0 + 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment