def union_by(a, b, fn):
  _a = set(map(fn, a))
  return list(set(a + [item for item in b if fn(item) not in _a]))

from math import floor

union_by([2.1], [1.2, 2.3], floor) # [2.1, 1.2]

 

相关文章:

  • 2021-08-01
  • 2021-09-21
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2021-11-09
猜你喜欢
  • 2021-07-17
  • 2021-10-25
  • 2021-10-21
  • 2021-07-05
  • 2022-01-05
  • 2021-09-28
  • 2021-07-04
相关资源
相似解决方案