Created
August 10, 2017 11:16
-
-
Save t-katsushima/4488ebcca3df571ef143c57ab98cc3e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type nat = Z | S of nat | |
let rec nat_of_int = function | |
| 0 -> Z | |
| n -> S (nat_of_int (n-1)) | |
let rec plus n m = | |
match n with | |
| Z -> m | |
| S n' -> plus n' (S m) | |
let times n m = | |
let rec calc n res = | |
match n with | |
| Z -> res | |
| S n' -> calc n' (plus m res) | |
in calc n Z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment