Created
March 30, 2021 13:54
-
-
Save ebresafegaga/65517b2073f579d7e6319e2796c47c17 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
(* (('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