Skip to content

Instantly share code, notes, and snippets.

@carcigenicate
Last active January 15, 2020 01:45
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 carcigenicate/d996ad0dd53791a94e627d2cbd3d4f12 to your computer and use it in GitHub Desktop.
Save carcigenicate/d996ad0dd53791a94e627d2cbd3d4f12 to your computer and use it in GitHub Desktop.
(defn my-merge
([lst1 lst2]
(my-merge lst1 lst2 nil))
([lst1 lst2 lst3]
(cond
(and (empty? lst1) (empty? lst2))
(reverse lst3)
(empty? lst1)
(recur nil (rest lst2) (cons (first lst2) lst3))
(empty? lst2)
(recur (rest lst1) nil (cons (first lst1) lst3))
(<= (first lst1) (first lst2))
(recur (rest lst1) lst2 (cons (first lst1) lst3))
:else
(recur lst1 (rest lst2) (cons (first lst2) lst3)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment