Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Quantum::Superpositions prob

by kvale (Monsignor)
on Mar 25, 2004 at 15:03 UTC ( [id://339755]=note: print w/replies, xml ) Need Help??


in reply to Quantum::Superpositions prob

Here is a non-quantum solution:
use warnings; use strict; my @a2 = qw/1 2 2 3 3 3 4 4 4 4 5 6 7/;#list of to_visit my @a1 = qw/1 2 3 4/;#list of visited my %visited; @visited{ @a1 } = 1; @a2 = grep {not exists $visited{ $_ }} @a2; print "list of to visit\n"; print_arrays(\@a2); print "\nlist visited\n"; print_arrays(\@a1); sub print_arrays { my $x = shift; for my $item1 ( @$x ) { print $item1,"\n"; } print "\n"; }
For the quantum solution, just sort the array.

-Mark

Replies are listed 'Best First'.
Re: Re: Quantum::Superpositions prob
by tommycahir (Acolyte) on Mar 25, 2004 at 15:13 UTC
    i want to try to keep them in the original order that they were entered on to the list, thats why i thought that Quantum::superpositions might just remove the duplicate value
      Then go with my solution. The grep function preserves the array order.

      -Mark

        L~R
        tanx for clearing up why the Quantum ::superpositions wasnt working

        kvale
        tanx a million that works a treat
        once again my ass been saved my the wise monks..

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found