Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Subtract arrays (RE: I have contributed a module to CPAN)

by tye (Cardinal)
on Sep 21, 2000 at 20:00 UTC ( #33507=note: print w/ replies, xml ) Need Help??


in reply to RE: I have contributed a module to CPAN
in thread I have contributed a module to CPAN

In the works unless I know of something better: a module to return the subtraction of the contents of arrays.

You mean something like:

# "Subtract" (remove) elements of @minus from @list: my %dup; @dup{@minus}= (); @list= grep { exists $dup{$_} } @list;

Update: Thanks to PrincePawn for noting that I left out "not" above.

        - tye (but my friends call me "Tye")


Comment on Subtract arrays (RE: I have contributed a module to CPAN)
Download Code
RE: Subtract arrays (RE: I have contributed a module to CPAN)
by Fastolfe (Vicar) on Sep 21, 2000 at 20:07 UTC
    Set::Scalar has functionality like this.. Set intersections, unions, subsets, etc.
RE: Subtract arrays (RE: I have contributed a module to CPAN)
by princepawn (Parson) on Sep 21, 2000 at 20:18 UTC
    This looks like the intersection
    grep { not exists $dup{$_} } @list
    should be the difference.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2015-07-03 21:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls