小编alu*_*lun的帖子

Clojure拉链功能

我需要通过组合给定seq的第一,第二等元素来构建seqs(vec vec).

经过快速搜索并查看备忘单.我还没有找到一个并完成自己的写作:

(defn zip 
  "From the sequence of sequences return a another sequence of sequenses
  where first result sequense consist of first elements of input sequences
  second element consist of second elements of input sequenses etc.

  Example:

  [[:a 0 \\a] [:b 1 \\b] [:c 2 \\c]] => ([:a :b :c] [0 1 2] [\\a \\b \\c])"
  [coll]
  (let [num-elems (count (first coll))
        inits (for [_ (range num-elems)] [])]
    (reduce (fn [cols elems] (map-indexed
                              (fn [idx coll] (conj …
Run Code Online (Sandbox Code Playgroud)

sequences clojure standard-library

2
推荐指数
1
解决办法
164
查看次数

标签 统计

clojure ×1

sequences ×1

standard-library ×1