Skip to content

Instantly share code, notes, and snippets.

@ujihisa
Created July 12, 2012 01:01
Show Gist options
  • Save ujihisa/3094901 to your computer and use it in GitHub Desktop.
Save ujihisa/3094901 to your computer and use it in GitHub Desktop.
(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