Calling concat on vectors returns a list. Being a total noob I would expect that the result would also be a vector. Why the conversion to list?
Example:
user=> (concat [1 2] [3 4] [5 6])
(1 开发者_JAVA百科2 3 4 5 6)
; Why not: [1 2 3 4 5 6] ?
concat returns a lazy sequence.
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.
you can convert it back to a vector with into:
user=> (into [] (concat [1 2] [3 4] [5 6]))
[1 2 3 4 5 6]
into uses transients so it's pretty quick about it.
精彩评论