Practice question from Higher-Order Functions
Complete the code to find the maximum value:
let numbers = [3; 7; 2; 9; 1]
let max = List.____ (fun ____ x -> if x > ____ then x else ____) numbers.[0] numbersAnswer
["fold","acc"]
Explanation
List.fold processes each element with an accumulator. The folder function compares each element x with the accumulator acc, keeping the larger value. It starts with numbers.[0] as the initial accumulator.