Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Just for total completeness ;-)

#!/usr/bin/perl + use strict; use warnings; use Set::Scalar; use Data::Dumper; my @arcb = ( 450, 625, 720, 645 ); my @arca = ( 625, 645 ); my $s1 = Set::Scalar->new(@arcb); my $s2 = Set::Scalar->new(@arca); @arcb = @{ $s1 - $s2 }; print Dumper( \@arcb ); __END__ $VAR1 = [ 450, 720 ];

Regards, Karl

P.S.: No, i don't get paid for endorsement of Set::Scalar ;-) And yes, i'm repeating myself: Re: Is it possible to find the matching words and the percentage of matching words between two texts?

Update

#!/usr/bin/perl + use Benchmark qw ( :hireswallclock cmpthese timethese ); use strict; # use warnings; use Set::Scalar; use Data::Dumper; use List::Compare; our @arcb = ( 450, 625, 720, 645 ); our @arca = ( 625, 645 ); sub davido { our @arcb; our @arca; @arcb = do { my %exclude; @exclude{@arca} = (); grep { !exists $exclude{$_} } @arcb; }; # print "@arcb\n"; } sub karlgoethebier { our @arcb; our @arca; my $s1 = Set::Scalar->new(@arcb); my $s2 = Set::Scalar->new(@arca); @arcb = @{ $s1 - $s2 }; # print Dumper( \@arcb ); } sub Lotus1 { our @arcb; our @arca; my $lc = List::Compare->new( \@arca, \@arcb ); @arcb = $lc->get_Ronly; # print "arcb: @arcb\n"; } sub LanX { my ( %arcb, %arca ); our @arcb; our @arca; @arcb{@arcb} = (); @arca{@arca} = (); delete @arcb{@arca}; @arcb = keys %arcb; # print Dumper( \@arcb ); } sub linuxer { our @arcb; our @arca; my %unwanted; $unwanted{$_}++ for @arca; @arcb = grep { !$unwanted{$_} } @arcb; # print "@arcb\n"; } sub nithins { our @arcb; our @arca; foreach my $a (@arca) { for ( my $i = 0 ; $i < scalar(@arcb) ; $i++ ) { delete $arcb[$i] if ( $a == $arcb[$i] ); } } # print "@arcb"; } # karlgoethebier; # Lotus1; # LanX; # davido; # linuxer; # nithins; my $results = timethese( -10, { 'karlgoethebier' => 'karlgoethebier', 'Lotus1' => 'Lotus1', 'LanX' => 'LanX', 'davido' => 'davido', 'linuxer' => 'linuxer', 'nithins' => 'nithins', } ); cmpthese($results); __END__ Benchmark: running LanX, Lotus1, davido, karlgoethebier, linuxer, +nithins for at least 10 CPU seconds... LanX: 10.513 wallclock secs (10.51 usr + 0.00 sys = 10.51 CPU) @ +378147.76/s (n=3974333) Lotus1: 10.4951 wallclock secs (10.49 usr + 0.00 sys = 10.49 CPU) + @ 23020.02/s (n=241480) davido: 10.5748 wallclock secs (10.58 usr + 0.01 sys = 10.59 CPU) + @ 378623.51/s (n=4009623) karlgoethebier: 10.4698 wallclock secs (10.47 usr + 0.00 sys = 10 +.47 CPU) @ 9713.28/s (n=101698) linuxer: 10.4635 wallclock secs (10.46 usr + 0.00 sys = 10.46 CPU +) @ 434439.87/s (n=4544241) nithins: 10.612 wallclock secs (10.61 usr + 0.00 sys = 10.61 CPU) + @ 589604.05/s (n=6255699) Rate karlgoethebier Lotus1 LanX davido linux +er nithins karlgoethebier 9713/s -- -58% -97% -97% -9 +8% -98% Lotus1 23020/s 137% -- -94% -94% -9 +5% -96% LanX 378148/s 3793% 1543% -- -0% -1 +3% -36% davido 378624/s 3798% 1545% 0% -- -1 +3% -36% linuxer 434440/s 4373% 1787% 15% 15% +-- -26% nithins 589604/s 5970% 2461% 56% 56% 3 +6% --

"The first priority of Set::Scalar is to be a convenient interface to sets. While not designed to be slow or big, neither has it been designed to be fast or compact. Jarkko Hietaniemi <jhi@iki.fi>"

«The Crux of the Biscuit is the Apostrophe»

 


In reply to Re: Removing elemets from an array by karlgoethebier
in thread Removing elemets from an array by lovelyMonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (5)
    As of 2014-07-10 04:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (198 votes), past polls