Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by Zaxo (Archbishop)
on Apr 09, 2005 at 18:07 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://446271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-23 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found