View generator.py
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 uniques(source, fmap=lambda x: x, restrictOn=lambda x: x): | |
"""Map a function over an iterable, and yield elements which are | |
unique according to the given restriction function. | |
An exception raised in the mapping or restriction function causes | |
that element to be silently skipped. | |
""" | |
seen = set() | |
for thing in source: |