RosettaCodeData/Task/Averages-Arithmetic-mean/OCaml/averages-arithmetic-mean-1.ml
2024-10-16 18:07:41 -07:00

5 lines
168 B
OCaml

let mean_floats = function
| [] -> 0.
| xs -> List.fold_left (+.) 0. xs /. float_of_int (List.length xs)
let mean_ints xs = mean_floats (List.map float_of_int xs)