Last active
April 18, 2017 16:31
-
-
Save mattearly/0b677b7119161eef0b18dd1871e3c005 to your computer and use it in GitHub Desktop.
This file contains 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
(*find i within the lst*) | |
let rec member i lst = | |
match lst with | |
[] -> false | |
| hd::tl -> hd = i || member i tl;; | |
(*with if else instead*) | |
let rec member i lst = | |
match lst with | |
[] -> false | |
| hd::tl -> if hd = i then true else member i tl;; | |
(*total up a list*) | |
let rec total lst = | |
match lst with | |
[] -> 0; | |
| hd::tl -> hd + total tl;; | |
(*compare function*) | |
let cmp x y = | |
if x > y then 1 | |
else if x < y then -1 | |
else 0;; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment