pub fn max(comptime T: type, slice: []const T) T T: typeslice: []const T3759
3760
3761
3762
3763
3764
3765
3766pub fn max(comptime T: type, slice: []const T) T {
assert(slice.len > 0);
var best = slice[0];
for (slice[1..]) |item| {
best = @max(best, item);
}
return best;
}
Returns the largest number in a slice. O(n).
slicemust not be empty.