-
-
Save anonymous/9579e13940aa172dc2013e3cf337f95c to your computer and use it in GitHub Desktop.
recursively extracting unique elements in nested lists.
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
def extract_unique_elements(a_list): | |
if isinstance(a_list, list) == False: | |
return {a_list} | |
uniq = [] | |
for elt in range(len(a_list)): | |
if a_list[elt] not in uniq: | |
uniq.append(a_list[elt]) | |
return extract_unique_elements(uniq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment