Created
October 15, 2013 11:10
-
-
Save mhinz/6990009 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
| fun max_eff (xs : int list) : int option = | |
| if null xs | |
| then NONE | |
| else | |
| let | |
| fun max_nonempty (xs : int list) : int = | |
| if null (tl xs) | |
| then hd xs | |
| else | |
| let | |
| val hd = hd xs | |
| val ans = max_nonempty (tl xs) | |
| in | |
| if hd > ans | |
| then hd | |
| else ans | |
| end | |
| in | |
| SOME (max_nonempty xs) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment