Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import reduce
- def partition(f, s):
- good = set()
- bad = set()
- def process(prev, curr):
- if f(curr):
- good.add(curr)
- else:
- bad.add(curr)
- reduce(process, s, -1)
- return good, bad
- print(partition(lambda x: x % 2 == 0, {1, 2, 3, 4}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement