Say I have several lists L1, L2,L3
an I want to correspond to each of the elements of Union[L1,L2,L3]
a list of list names to which it belongs.
How to do it efficiently? I know it is silly question but to save time I decide just to ask it.
lists = {L1, L2, L3} = {{1, 2, 3}, {2, 3, 4}, {1, 2, 3, 4, 5}};
labels = {"L1", "L2", "L3"};
Merge[Identity][AssociationThread @@@ Thread[{lists, labels}]]
<|1 -> {"L1", "L3"}, 2 -> {"L1", "L2", "L3"}, 3 -> {"L1", "L2", "L3"}, 4 -> {"L2", "L3"}, 5 -> {"L3"}|>