mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 01:52:11 +03:00
29 lines
451 B
Plaintext
29 lines
451 B
Plaintext
module Data.Nat;
|
||
inductive ℕ {
|
||
zero : ℕ;
|
||
suc : ℕ → ℕ;
|
||
};
|
||
|
||
infixl 6 +;
|
||
+ : ℕ → ℕ → ℕ;
|
||
+ zero b ≔ b;
|
||
+ (suc a) b ≔ suc (a + b);
|
||
|
||
infixl 7 *;
|
||
* : ℕ → ℕ → ℕ;
|
||
* zero b ≔ zero;
|
||
* (suc a) b ≔ b + a * b;
|
||
|
||
import Data.Bool;
|
||
open Data.Bool;
|
||
|
||
even : ℕ → Bool;
|
||
odd : ℕ → Bool;
|
||
|
||
even zero ≔ true;
|
||
even (suc n) ≔ odd n;
|
||
|
||
odd zero ≔ false;
|
||
odd (suc n) ≔ even n;
|
||
end;
|