According to this answer, to obtain the maximum of an array we can do:
let nums = [1, 6, 3, 9, 4, 6];
let numMax = nums.reduce(Int.min, { max($0, $1) })
How can we do the same for an Array<Float>
, since there's no min
and max
for Float
?
let floats: Array<Float> = [2.45, 7.21, 1.35, 10.22, 2.45, 3];