reduce<K, V> static method
Reduces acc by calling fn on every element of list. fn should modify acc and then return it.
Call like FP.reduce<K,V>(fn, acc)(list)
Implementation
static V Function(List<K> list) reduce<K, V>(
V Function(V acc, K elem) fn, V acc) {
return (final List<K> list) {
if (list.isEmpty) {
return acc;
}
acc = fn(acc, list.first);
return reduce<K, V>(fn, acc)(list.skip(1).toList());
};
}