Last active
January 15, 2020 01:45
-
-
Save carcigenicate/d996ad0dd53791a94e627d2cbd3d4f12 to your computer and use it in GitHub Desktop.
This file contains 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 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