Skip to content

Instantly share code, notes, and snippets.

@kurogelee
Created March 28, 2014 10:04
Show Gist options
  • Save kurogelee/9829315 to your computer and use it in GitHub Desktop.
Save kurogelee/9829315 to your computer and use it in GitHub Desktop.
Clojureでzip関数を作ってみる ref: http://qiita.com/kurogelee/items/f8e22c230dd2b16110c7
(zipseq [1 2 3] [:a :b :c]) ; => ((1 :a) (2 :b) (3 :c))
(zipseq [1 2] [:a :b] [:c :d]) ; => ((1 :a :c) (2 :b :d))
(zipseq [1 2 3]) ; => ((1) (2) (3))
(defn zipseq [& colls] (partition (count colls) (apply interleave colls)))
(defn zipseq
([coll] (partition 1 coll))
([c1 & colls] (let [c (cons c1 colls)] (partition (count c) (apply interleave c)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment