Advertisement
STANAANDREY

lsd6 set 4

Nov 8th, 2022
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. from functools import reduce
  2.  
  3.  
  4. def partition(f, s):
  5.     good = set()
  6.     bad = set()
  7.  
  8.     def process(prev, curr):
  9.         if f(curr):
  10.             good.add(curr)
  11.         else:
  12.             bad.add(curr)
  13.  
  14.     reduce(process, s, -1)
  15.     return good, bad
  16.  
  17.  
  18. print(partition(lambda x: x % 2 == 0, {1, 2, 3, 4}))
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement