perl6 What is a quick way to de-select array or list elements?
问题 To select multiple elements from an array in perl6, it is easy: just use a list of indices: > my @a = < a b c d e f g >; > @a[ 1,3,5 ] (b d f) But to de-select those elements, I had to use Set: > say @a[ (@a.keys.Set (-) (1,3,5)).keys.sort ] (a c e g) I am wondering if there is an easier way because the arrays I use are often quite large? 回答1: sub infix:<not-at> ($elems, @not-ats) { my $at = 0; flat gather for @not-ats -> $not-at { when $at < $not-at { take $at++ xx $not-at - $at } NEXT { $at