Skip to content

Instantly share code, notes, and snippets.

@mhinz
Created October 15, 2013 11:10
Show Gist options
  • Save mhinz/6990009 to your computer and use it in GitHub Desktop.
Save mhinz/6990009 to your computer and use it in GitHub Desktop.
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