List intersection based on function
Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.
- Create a
set
, usingmap()
to applyfn
to each element inb
. - Use a list comprehension in combination with
fn
ona
to only keep values contained in both lists.