Created
September 28, 2013 18:16
-
-
Save canburak/6744823 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
def merge_lists(l1, l2): | |
# If any of the lists are epty, return the other list | |
if not l1: return l2 | |
if not l2: return l1 | |
if l1[0] <= l2[0]: | |
# Prepend the smaller item to the merged version of the rest | |
return [l1[0]] + merge_lists(l1[1:], l2) | |
else: | |
return merge_lists(l2, l1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment