Created
August 5, 2011 18:04
-
-
Save pcomans/1128131 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 acc-tail-merge | |
"Trololo" | |
[acc list1 list2 func] | |
(cond | |
(empty? list1) (concat acc list2) | |
(empty? list2) (concat acc list1) | |
:else (let [[first1 & rest1] list1 | |
[first2 & rest2] list2 | |
[small-first small-rest large-list] (if (func first1 first2) [first1 rest1 list2] [first2 rest2 list1]) | |
new-acc (concat acc [small-first])] | |
(recur new-acc small-rest large-list func)))) | |
(defn tail-merge | |
"Lololo" | |
[list1 list2 func] | |
(acc-tail-merge [] (seq list1) (seq list2) func)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment