Created
July 12, 2012 01:01
-
-
Save ujihisa/3094901 to your computer and use it in GitHub Desktop.
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 zip [xs ys] | |
(lazy-seq (if (not-empty ys) | |
(cons [(first xs) (first ys)] | |
(zip (rest xs) (rest ys))) | |
(map (fn [i] [i nil]) xs)))) | |
(defn f [xs] | |
(map (fn [[a b]] | |
(if (not (nil? b)) [a 0] [a 1])) | |
(zip xs (rest xs)))) | |
(prn (f ['a 'b 'c 'd 'e])) | |
(prn (f ['c])) | |
(prn (doseq [tuple (f (iterate inc 12312))] | |
(prn tuple) | |
(Thread/sleep 1000))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment