Using a slice in the delete call will sidestep the for-loop. The map can also be replaced with a slice.
hash_slice => sub { my %ha; @ha{0..$#numbers} = @numbers; delete @ha{@indices}; my @output = @ha{sort keys %ha}; join("\0", @output) eq join("\0", @expect) or die if TEST; },
In reply to Re^2: Fastest way to "pick without replacement"
by swl
in thread Fastest way to "pick without replacement"
by haukex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |