4 ms·
That is using map, not implementing map. Implementing map: function map(f, ary) { var ret = []; for(var i = 0; i < ary.length; i+= 1) {
by i_s 12y ago
That is using map, not implementing map.
Implementing map:
function map(f, ary) {
var ret = [];
for(var i = 0; i < ary.length; i+= 1) {
ret.push(f(ary[i]));
}
return ret;
}
Though that is not a good example by the op, because that is what you do:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2556-#L2557 https://github.com/clojure/clojure/blob/master/src/clj/cloju...
- deleted 12y ago[deleted]
- gotofritz 12y agoI would do it like this... function map(f, ary) { return [].map.call(ary, f); }