Skip to content

Instantly share code, notes, and snippets.

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: