I am new to F # and have written a simple algorithm to get used to a language that requires argMax . Does the standard library have a function to search for a list item that maximizes the function? That is, if there is an existing function that behaves as follows:
let argMax f xs = let rec go a fa zs = match zs with | [] -> a | z :: zs' -> let fz = fz if fz > fa then go z fz zs' else go a fa zs' match xs with | [] -> invalidArg "xs" "empty" | x :: xs' -> go x (fx) xs'
source share