3 ms·
mapv and reduce-kv are a great addition; not so much as a feature per se, but rather as a testament of the core team being on the lookout for design patterns th
by simonb 14y ago
mapv and reduce-kv are a great addition; not so much as a feature per se, but rather as a testament of the core team being on the lookout for design patterns that are actually symptoms of lacks in the language [http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatu...].
- spacemanaki 14y agoI'm not really sure what you mean... unless I'm missing something mapv is the same as (into [] (map ...)), and based on the source that appears to be exactly what it is. reduce-kv is a bit more complicated but it's not really a huge leap from reduce. Nice additions, to be sure, but are either really design patterns that indicate some lack in Clojure 1.3?
- pmjordan 14y agoI think it's more that everyone previously had the same helper function/macro in their code base with a different name. If everyone needs the exact same thing, the standard library is a better place for it.
- simonb 14y agoCodebases were littered with (vec (map ...)) and (reduce (fn [acc [k v]] ...)) patterns which are nothing but noise. This change removes the need for that, makes the intention clearer and in the case of reduce-kv removes the need for lambdas in some cases (where it was used only for destructuring).
- lukev 14y agoThey are actually much more efficient because they have type-specific implementations that operate directly on the underlying data structures, rather than constructing intermediate MapEntry objects and then mapping/reducing across those.
- deleted 14y ago[deleted]