mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-11 13:59:31 -06:00
24 lines
464 B
Plaintext
24 lines
464 B
Plaintext
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)) ;
|