在vectors上调用concat会返回一个列表。作为一个完全的菜鸟,我希望结果也是一个向量。为什么要转换为list?
示例:
user=> (concat [1 2] [3 4] [5 6])
(1 2 3 4 5 6)
; Why not: [1 2 3 4 5 6] ?发布于 2010-04-26 09:00:13
concat返回一个惰性序列。
user=> (doc concat)
-------------------------
clojure.core/concat
([] [x] [x y] [x y & zs])
Returns a lazy seq representing the concatenation of the elements in the supplied colls.您可以使用into将其转换回向量:
user=> (into [] (concat [1 2] [3 4] [5 6]))
[1 2 3 4 5 6]into使用瞬变,所以它非常快。
https://stackoverflow.com/questions/2710512
复制相似问题