Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import functools
- def subset(s, f):
- ans = set()
- def reduer(acc, elem):
- if f(elem):
- ans.add(elem)
- functools.reduce(reduer, s, None)
- return ans
- print(subset({1, 2, 3, 4, 5, 6, 7, 81}, lambda x: x & 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement