max method
Functions, used to find the maximum value for any given array
axis is null by default to find max values of columns use zero and for rows use 1
Implementation
List max(List list, {int? axis}) {
try {
if (!_checkArray(list)) {
throw new Exception('Not 2d array');
}
var result = [];
if (axis == null) {
list = flatten(list);
return [arrMax(list)];
} else if (axis > 1 || axis < 0) {
throw new Exception('Only two axis 0 and 1');
} else {
if (axis == 1) {
for (var i = 0; i < list.length; i++) {
if (_isList(list[i])) {
result.add(arrMax(list[i]));
}
}
return result;
} else {
list = transpose(list);
for (var i = 0; i < list.length; i++) {
if (_isList(list[i])) {
result.add(arrMax(list[i]));
}
}
return result;
}
}
} catch (e) {
throw new Exception(e);
}
}