I am trying to figure out how to compute the intersection of an unknown number of sets, realized as key => value pairs in a hash. More explicitly, given a hash:
For such a hash, we can percieve it as a set of sets, where a set 'name' is given by the value. Thus, for the hash above, we would have 3 sets (value1, value2 and value3). Now, i would like to compute the intersection of the members of these sets (in this case, the intersection would have 1 member, namely key2). One of the problems is that i do not have an a priori knowledge of the number of sets to compare. I have looked at List::Compare, which i believe could be useful, but i haven't found a solution yet :(
Please, any help would be highly appreciated! Best, Tine
> For such a hash, we can percieve it as a set of sets, where a set > 'name' is given by the value. Thus, for the hash above, we would have > 3 sets (value1, value2 and value3). Now, i would like to compute the > intersection of the members of these sets (in this case, the > intersection would have 1 member, namely key2). One of the problems is > that i do not have an a priori knowledge of the number of sets to > compare.
That makes no sense - you can only have one of each key since keys are unique. If you were to add a key a second time it would replace the prior value for that key. Hence you would have: