实际上,从 Clojure 1.4.0 开始,这样做的首选方法是使用mapv,这就像map除了它的返回值是一个向量。这是迄今为止最有效的方法,根本没有不必要的中间分配。
Clojure 1.5.0 将带来一个新的 reducers 库,它将提供一个通用的方法来创建map、filter、等take,drop同时创建可用于into []. 您可以在 1.5.0 alpha 版和最近的 ClojureScript 标记版本中使用它。
As for (vec some-seq) and (into [] some-seq), the first ultimately delegates to a Java loop which pours some-seq into an empty transient vector, while the second does the same thing in very efficient Clojure code. In both cases there are some initial checks involved to determine which approach to take when constructing the final return value.
vec and into [] are significantly different for Java arrays of small length (up to 32) -- the first will alias the array (use it as the tail of the newly created vector) and demands that the array not be modified subsequently, lest the contents of the vector change (see the docstring); the latter creates a new vector with a new tail and doesn't care about future changes to the array.