Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by tye (Sage)
on Sep 21, 2000 at 20:00 UTC ( [id://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")

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://33507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found