Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: most efficient way to implement "A without B"

by Zaxo (Archbishop)
on Apr 09, 2005 at 18:07 UTC ( #446271=note: print w/replies, xml ) Need Help??


in reply to most efficient way to implement "A without B"

A hash is the usual way to improve the efficiency of lookup.

my @a_not_b = do { my %b; @b{@b} = (); grep { not exists $b{$_} } @a; };
No sorting needed.

After Compline,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://446271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2020-05-25 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (146 votes). Check out past polls.

    Notices?