Skip to content

Instantly share code, notes, and snippets.

@pcomans
Created August 5, 2011 18:04
Show Gist options
  • Save pcomans/1128131 to your computer and use it in GitHub Desktop.
Save pcomans/1128131 to your computer and use it in GitHub Desktop.
(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