mirror of
https://github.com/anoma/juvix.git
synced 2025-01-05 22:46:08 +03:00
019579bba2
* Closes #2361 * Aligns `case` and `let`
47 lines
763 B
Plaintext
47 lines
763 B
Plaintext
module Case;
|
|
|
|
import Stdlib.Prelude open;
|
|
|
|
isZero : Nat → Bool
|
|
| n :=
|
|
case n of {
|
|
| zero := true
|
|
| k@(suc _) := false
|
|
};
|
|
|
|
id' : Bool → {A : Type} → A → A
|
|
| b :=
|
|
case b of {
|
|
| true := id
|
|
| false := id
|
|
};
|
|
|
|
pred : Nat → Nat
|
|
| n :=
|
|
case n of {
|
|
| zero := zero
|
|
| suc n := n
|
|
};
|
|
|
|
appIf : {A : Type} → Bool → (A → A) → A → A
|
|
| b f :=
|
|
case b of {
|
|
| true := f
|
|
| false := id
|
|
};
|
|
|
|
appIf2 : {A : Type} → Bool → (A → A) → A → A
|
|
| b f a :=
|
|
case b of {
|
|
| true := f
|
|
| false := id
|
|
}
|
|
a;
|
|
|
|
nestedCase1 : {A : Type} → Bool → (A → A) → A → A
|
|
| b f :=
|
|
case b of {
|
|
| true := case b of {_ := id}
|
|
| false := id
|
|
};
|