Created
December 3, 2009 11:09
-
-
Save angerman/248074 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 combine [A B] | |
(loop [a+ A | |
b+ B | |
acc []] | |
(let [a (first a+) | |
b (first b+)] | |
(if (not a) ;; list a ended | |
(concat acc b+) | |
(if (not b) ;; list b ended | |
(concat acc a+) | |
(if (= a b) ;; items are the same | |
(recur (next a+) (next b+) (conj acc a)) | |
(if (< a b) ;; either way | |
(recur (next a+) b+ (conj acc a)) | |
(recur a+ (next b+) (conj acc b))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment