Filter out elements in tuple from list of tuples

Viewed 51

I have an list of tuples looking like this:

[("APPLE",["APPLE","BANANA","PEAR"]),("ANANAS",["ANANAS","BANANA","APPLE"])]

However I would like to remove any occurrence of the first element in the tuple from the snd list in the tuple. So I would like the list of tuples to look like:

[("APPLE",["BANANA","PEAR"]),("ANANAS",["BANANA","APPLE"])]
1 Answers

I solved it using:

map (\(x, y) -> (x, filter (/=x) y)) list
Related