在矢量上调用concat会返回一个列表.作为一个总的菜鸟我会期望结果也是一个矢量.为什么要转换成列表?
例:
user=> (concat [1 2] [3 4] [5 6])
(1 2 3 4 5 6)
; Why not: [1 2 3 4 5 6] ?
Run Code Online (Sandbox Code Playgroud)
dno*_*len 36
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.
Run Code Online (Sandbox Code Playgroud)
您可以将其转换回带有以下内容的向量:
user=> (into [] (concat [1 2] [3 4] [5 6]))
[1 2 3 4 5 6]
Run Code Online (Sandbox Code Playgroud)
使用瞬态,所以它很快.
| 归档时间: |
|
| 查看次数: |
11329 次 |
| 最近记录: |