Skip to content

Instantly share code, notes, and snippets.

@ebresafegaga
Created March 30, 2021 13:54
Show Gist options
  • Save ebresafegaga/65517b2073f579d7e6319e2796c47c17 to your computer and use it in GitHub Desktop.
Save ebresafegaga/65517b2073f579d7e6319e2796c47c17 to your computer and use it in GitHub Desktop.
?
(* (('a * 'b as 'a) * 'b) list -> 'a *)
let rec maximum xs =
let aux xs =
match xs with
| [(a,b)] -> (a,b)
| (a, b) :: xs ->
let (a', b') = maximum xs in
if b > b' then
(a, b)
else
(a', b')
| [] -> failwith "max of empty"
in
aux xs |> fst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment