mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-26 05:01:34 +03:00
a972778eab
They don't all pass yet, for minor reasons. Coming shortly... Unfortunately the startup overhead for chez is really noticeable here!
51 lines
856 B
Plaintext
51 lines
856 B
Plaintext
data Bool : Type where
|
|
False : Bool
|
|
True : Bool
|
|
|
|
not : Bool -> Bool
|
|
not False = True
|
|
not True = False
|
|
|
|
data Nat : Type where
|
|
Z : Nat
|
|
S : Nat -> Nat
|
|
|
|
plus : Nat -> Nat -> Nat
|
|
plus Z y = y
|
|
plus (S k) y = S (plus k y)
|
|
|
|
ack : Nat -> Nat -> Nat
|
|
ack Z n = S n
|
|
ack (S k) Z = ack k (S Z)
|
|
ack (S j) (S k) = ack j (ack (S j) k)
|
|
|
|
foo : Nat -> Nat
|
|
foo Z = Z
|
|
foo (S Z) = (S Z)
|
|
foo (S (S k)) = foo (S k)
|
|
|
|
foo' : Nat -> Nat
|
|
foo' Z = Z
|
|
foo' (S Z) = (S Z)
|
|
foo' (S p@(S k)) = foo' p
|
|
|
|
data Bin : Type where
|
|
EPS : Bin
|
|
C0 : Bin -> Bin
|
|
C1 : Bin -> Bin
|
|
|
|
foom : Bin -> Nat
|
|
foom EPS = Z
|
|
foom (C0 EPS) = Z
|
|
foom (C0 (C1 x)) = S (foom (C1 x))
|
|
foom (C0 (C0 x)) = foom (C0 x)
|
|
foom (C1 x) = S (foom x)
|
|
|
|
pfoom : Bin -> Nat
|
|
pfoom EPS = Z
|
|
pfoom (C0 EPS) = Z
|
|
pfoom (C0 (C1 x)) = S (pfoom (C0 x))
|
|
pfoom (C0 (C0 x)) = pfoom (C0 x)
|
|
pfoom (C1 x) = S (foom x)
|
|
|