News for hackers. Stuff that matters.
Re:Simple apply/filter/reduce package in Go by falcolas on Friday April 03, 2015 @11:06AM (#9316269)
List comprehension produces a different output than reduce (since reduce does not have to produce a list). Reduce and for loops are better compared.

For loops make the logic occurring on each operator explicit and in the current frame of reference, as opposed to reduce, which splits the logic from the point of operation.

Also, when reduce is used to produce an artifact similar to a list comprehension: the list comprehension is going to be better optimized, more comprehensible for many programmers, and with two character changes can be turned into a generator instead of a memory-heavy list.

There are no comments on this comment yet.