blob: f67dc55ce55c0950557a77ae858d5d95688c6972 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
data Nat : Type where {
Zero : Nat ;
Succ : (n:Nat) -> Nat ;
} ;
plus : Nat -> Nat -> Nat ;
plus Zero y = y ;
plus (Succ x) y = Succ (plus x y) ;
pred : Nat -> Nat ;
pred Zero = Zero ;
pred (Succ n) = n ;
natToInt : Nat -> Int ;
natToInt Zero = 0 ;
natToInt (Succ n) = 1 + natToInt n ;
plus : Nat -> Nat -> Nat ;
plus Zero y = y ;
plus (Succ x) y = Succ (plus x y) ;
intToNat : Int -> Nat ;
intToNat n = if n == 0 then Zero else Succ (intToNat (n-1)) ;
|