nat : type.
z : nat.
succ : nat → nat.
rec add : ( ⊢ nat) → ( ⊢ nat) → ( ⊢ nat) =
fn x ⇒ fn y ⇒
case x of
| [ ⊢ z] ⇒ y
| [ ⊢ succ ] ⇒ let [ ⊢ ] = add [ ⊢ ] y in [ ⊢ succ ];
list : type.
nil : list.
cons : nat → list → list.
rec length : ( ⊢ list) → ( ⊢ nat) =
fn l ⇒
case l of
| [ ⊢ nil] ⇒ [ ⊢ z]
| [ ⊢ cons ] ⇒ let [ ⊢ ] = length [ ⊢ ] in [ ⊢ succ ];
rec map : (( ⊢ nat) → ( ⊢ nat)) → ( ⊢ list) → ( ⊢ list) =
fn f ⇒ fn l ⇒
case l of
| [ ⊢ nil] ⇒ [ ⊢ nil]
| [ ⊢ cons ] ⇒ let [ ⊢ ] = f [ ⊢ ] in let [ ⊢ ] = map f [ ⊢ ] in
[ ⊢ cons ];
© Computation and Logic Group
Department of Computer Science, McGill University
3480 University Street, Montreal, Quebec, Canada, H3A 0E9