3 ms·
It does if you're familiar with the common high-order functions used in functional programming.
by rootlocus 13y ago
It does if you're familiar with the common high-order functions used in functional programming.
- forrestthewoods 13y agoIf you are familiar with both C++ and common high-order functions used in functional programming I still think that squareVec4 is, by leaps and bounds, the most readable. squareVec4 is simple, concise, and leaves little to no room for ambiguity. squareVec6 is a monstrosity that requires reading more text that contains more complicated ascii and involves more concepts. And for the author to then claim that making use of "cool stuff" in <algorithm> is more maintainable code? That's just crazy talk man!
- mercurial 13y agoIsn't this an artifact of C++ rather than a general truth, though? If you could just invoke something like: return v.fold([], def (acc, i) { acc.push(i*i) }); Or better: return v.map(def(i) { i * i }) Something like 'map' in this case is much more appropriate, since it's operation on a collection which returns a new collection with a given operation applied on each element.