4 ms·
> combinations of .map, .filter, .reduce, etc are often less readable than doing the same thing in a nested loop. I often find map/reduce/filter easier to read
by e12e 3y ago
> combinations of .map, .filter, .reduce, etc are often less readable than doing the same thing in a nested loop.
I often find map/reduce/filter easier to read when using named functions (or lazy data structures ) for intermediary results - depending on the language/runtime that might imply more allocations - or not.
Eg pseudocode:
Integers.filter(//non-obvious prime sieve).sum()
Vs
Primes = Integer.filter(//non-obvious prime sieve)
Primes.sum()
Or lifting the anonymous filter to primes()-filter:
Integers.primes().sum()