Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 about the Monastery: (13)
As of 2014-12-27 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls