3 ms·
Isn'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) }
by mercurial 13y ago
Isn'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.