I'd go one step further and make a hash of the contents of @$b for lookup purposes. It's faster to look up values in a hash than in an array.
sub exclude { my ($a, $b) = @_; my %lookup = map { $_ => undef } @$b; for (1..@$a) { my $i = shift @$a; push(@$a, $i) unless exists $lookup{$i}; } @$a; }
In reply to Re: Re: exclude all members of @a from @b
by tomhukins
in thread exclude all members of @a from @b
by zane
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |