This works
sub test_ordered { #test if two arrays are ordered in same way #assuming no duplicate and left array is always #be greater/superset or equal to the right one # L R my ($ar1,$ar2)= @_; my %h; @h{@$ar1} = (0..$#{$ar1}); my $last = -1; foreach (@h{@$ar2}) { return 0 unless $_ >= $last; $last = $_; } return 1; }
In reply to Re: Testing if Two Arrays are Ordered in a Same Way
by ikegami
in thread Testing if Two Arrays are Ordered in a Same Way
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |