in reply to Re: Using hashes for set operations...
in thread Using hashes for set operations...

well this my %intersection = grep $set1{$_}, keys %set2; is wrong, you're assigning a list of keys to a hash.

and you missed so many points from my post that I assume that you only read the headings... or how do you want to intersect sets of objects like this?

Cheers Rolf

Replies are listed 'Best First'.
Re^3: Using hashes for set operations...
by John M. Dlugosz (Monsignor) on May 21, 2011 at 19:08 UTC
    and [he] missed so many points from my post that I assume that you only read the headings
    I've noticed a trend for quantity at the expense of quality, in general.
      Answering the replies to my posts has been taking a lot out of me, and taking a lot of time away from my other answers.
        Maybe you need a vacation. Spend some time on the beach, or the slopes, as your interests may lie.
        Answering the replies to my posts has been taking a lot out of me
        First, not all replies require answers (this one doesn't, for example). Second, you don't always *have* to get in the last word. Every discussion has to end at some point.

        If you don't have time to do new subjects justice, don't reply at all.

Re^3: Using hashes for set operations...
by ikegami (Patriarch) on May 22, 2011 at 05:18 UTC

    Sorry, missing map { $_ => 1 }

    my %set1 = map { $_ => 1 } @array1; my %set2 = map { $_ => 1 } @array2; my %intersection = map { $_ => 1 } grep $set1{$_}, keys %set2;

    and you missed so many points from my post that I assume that you only read the headings..

    Are you trying to imply that I should have told you you need to use a hash to get the original from the stringification even you already know that?

    Or are you referring to request to avoid loops? Yeah, I missed that bit of nonsense. It's impossible to find the intersection of two sets without looping over the two sets.