Created
March 28, 2014 10:04
-
-
Save kurogelee/9829315 to your computer and use it in GitHub Desktop.
Clojureでzip関数を作ってみる ref: http://qiita.com/kurogelee/items/f8e22c230dd2b16110c7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(zipseq [1 2 3]) ; => ((1) (2) (3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn zipseq [& colls] (partition (count colls) (apply interleave colls))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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