Skip to content

Instantly share code, notes, and snippets.

@aymanosman
Last active February 4, 2020 01:42
Show Gist options
  • Save aymanosman/9db1db11755ef4b4759c4ee9a4bdb515 to your computer and use it in GitHub Desktop.
Save aymanosman/9db1db11755ef4b4759c4ee9a4bdb515 to your computer and use it in GitHub Desktop.
The Little Typer Exercise 3.4
#lang pie
(claim >
(-> Nat Nat Nat))
(define >
(lambda (n)
(rec-Nat n
(the (-> Nat Nat) (lambda (m) 0))
(lambda (n-1 n-1>)
(lambda (m)
(rec-Nat m
1
(lambda (m-1 _)
(n-1> m-1))))))))
(claim max
(-> Nat Nat Nat))
(define max
(lambda (n m)
(rec-Nat (> n m)
m
(lambda (_ _) n))))
(check-same Nat 0 (max 0 0))
(check-same Nat 1 (max 1 0))
(check-same Nat 1 (max 0 1))
(check-same Nat 2 (max 2 1))
(check-same Nat 2 (max 1 2))
@banbh
Copy link

banbh commented Feb 4, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment