Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to Test if Two Arrays are Ordered in the Same Way

by monkfan (Curate)
on Jun 09, 2005 at 12:23 UTC ( [id://465085]=note: print w/replies, xml ) Need Help??


in reply to How to Test if Two Arrays are Ordered in the Same Way

Ok, this is one the answer given by most revered tlm to me the other day:
sub test_ordered { my ( $ref, $test ) = @_; # $i scans the indices of @$ref; # $matched keeps count of # of elements matched in @$test; my ( $i, $matched ) = ( 0, 0 ); OUTER: for ( @$test ) { while ( $i < @$ref or return 0 ) { if ( $ref->[ $i++ ] eq $_ ) { last OUTER if ++$matched == @$test; last; } } } return 1; }
More can be found here. Don't vote my root posting but vote those remarkable answers you will find there.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-03-28 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found