Created
February 12, 2016 17:10
-
-
Save timotree3/82ec4e8ce4b514c2c270 to your computer and use it in GitHub Desktop.
Keep differences
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 keepDiff(new,old=None): | |
result = [] | |
if(not(old) or old==new): | |
return new | |
else: | |
try: | |
for i in range(0,len(new)): | |
try: | |
if(old[i]==new[i]): | |
result.append(None) | |
else: | |
result.append(keepDiff(new[i],old[i])) | |
except IndexError: | |
result.append(new[i]) | |
except TypeError: | |
result=new | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment