4 ms·
It can, but using it that way is considered non-idiomatic in Clojure. The intent of using variants of map is to produce a collection with each element transform
by Zak 9y ago
It can, but using it that way is considered non-idiomatic in Clojure. The intent of using variants of map is to produce a collection with each element transformed. Someone who reads the code might reasonably expect not to find side effects inside any variety of map.
Clojure provides doseq and run! for side effects on collections, and both return nil. One might get the impression that these design choices are intended to discourage the programmer from complecting transformations of sequences with performing side effects on their elements.
Most of the time, you can replace one with another, such as pmap (lazy, parallel) and have the program behave the same way. Using mapv for side effects breaks this assumption.