什么是交错的两个向量最简单的方法n+1 和n成员?
(def a [:a :c :e])
(def b [:b :d])
(interleave a b ); truncates to shortest list
[:a :b :c :d]
;what I would like.
(interleave-until-nil a b)
[:a :b :c :d :e]
Run Code Online (Sandbox Code Playgroud)
首先,将其余部分与反转的参数交错.
(cons (first a) (interleave b (rest a)))
;=> (:a :b :c :d :e)
Run Code Online (Sandbox Code Playgroud)