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..