Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ato/248080 to your computer and use it in GitHub Desktop.
Save ato/248080 to your computer and use it in GitHub Desktop.
(defn lazy-combine [xs ys]
(lazy-seq
(if-let [[x & xs*] xs]
(if-let [[y & ys*] ys]
(cond (= x y) (cons x (lazy-combine xs* ys*))
(< x y) (cons x (lazy-combine xs* ys))
(> x y) (cons y (lazy-combine xs ys*)))
xs) ; no more ys
ys))) ; no more xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment