Created
January 12, 2018 19:14
-
-
Save scresante/b4ebfb24415a34ca65eef60d10144265 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 runningUniq(anArray, compare=lambda x,y: x==y): | |
""" non-memory efficient linear deduplicator """ | |
retAr = [] | |
for n, elem in enumerate(anArray): | |
if n == 0: | |
last = elem | |
retAr.append(elem) | |
continue | |
if compare(elem, last): | |
last = elem | |
continue | |
else: | |
last = elem | |
retAr.append(elem) | |
return retAr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment