交织两个序列,不得使用interleave操作
Write a function which takes two sequences and returns the first item from each, then the second item from each, then the third, etc.
用loop循环搞定
(loop [s1 a
s2 b
ret (empty a)]
(if (or (empty? s1)
(empty? s2))
ret
(recur (rest s1)
(rest s2)
(conj ret
(first s1)
(first s2)) )))
看到github上有个比较巧妙的方式
mapcat vector
(mapcat vector [1 2 3] [:a :b :c])
=> (1 :a 2 :b 3 :c)