Last active
October 15, 2015 11:40
-
-
Save ayu-mushi/31aed337e6117b00ee66 to your computer and use it in GitHub Desktop.
Agdaはじめます
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 | |
b : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C | |
b x y z = x (y z) | |
c : {A B C : Set} -> (A -> B -> C) -> B -> A -> C | |
c x y z = x z y | |
k : {A B : Set} -> A -> B -> A | |
k x y = x | |
w : {A B : Set} -> (A -> A -> B) -> A -> B | |
w x y = x y y |
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
{- definition of ℕ and fib -} | |
data ℕ : Set where | |
O : ℕ | |
S : ℕ → ℕ | |
pred : ℕ → ℕ | |
pred O = O | |
pred (S n) = n | |
_+_ : ℕ → ℕ → ℕ | |
O + n = n | |
(S n) + m = S (n + m) | |
_*_ : ℕ → ℕ → ℕ | |
O * n = O | |
(S n) * m = m + (n * m) | |
_^_ : ℕ → ℕ → ℕ | |
n ^ O = S O | |
n ^ (S m) = n * (n ^ m) | |
fib : ℕ → ℕ | |
fib O = O | |
fib (S O) = S O | |
fib (S (S n)) = (fib (S n)) + (fib n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment