The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Intersection of hash keys?
 There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic. There was an error processing your request. Please try again. Standard view   View as tree
 3 messages

From:
To:
Cc:
Followup To:
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Feb 10 2011, 10:21 am
Newsgroups: comp.lang.perl.tk
From: Pinkerbot <tine.las...@gmail.com>
Date: Thu, 10 Feb 2011 07:21:33 -0800 (PST)
Local: Thurs, Feb 10 2011 10:21 am
Subject: Intersection of hash keys?
Hi all,

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:

%hash = (
key1 => 'value1',
key1 => 'value1',

key2 => 'value2',
key3 => 'value3',
);

To post a message you must first join this group.
You do not have the permission required to post.
More options Feb 10 2011, 10:37 am
Newsgroups: comp.lang.perl.tk
From: Pinkerbot <tine.las...@gmail.com>
Date: Thu, 10 Feb 2011 07:37:32 -0800 (PST)
Local: Thurs, Feb 10 2011 10:37 am
Subject: Re: Intersection of hash keys?
Sorry - somehow i posted before i was done ...
Anyhow, given a hash, e.g.:

%hash = (
key1 => 'value1',
key2 => 'value1',
key2 => 'value2',
key1 => 'value3',
key2 => 'value3',
key3 => 'value3'
);

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

To post a message you must first join this group.
You do not have the permission required to post.
More options Feb 10 2011, 10:54 am
Newsgroups: comp.lang.perl.tk
From: "\$Bill" <n...@SPAMOLAtodbe.com>
Date: Thu, 10 Feb 2011 07:54:33 -0800
Local: Thurs, Feb 10 2011 10:54 am
Subject: Re: Intersection of hash keys?
On 2/10/2011 7:37 AM, Pinkerbot wrote:

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:

%hash = (
key1 => 'value3',
key2 => 'value3',
key3 => 'value3'
);

another manner.

PS: What does it have to do with Tk ?