Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/201663 to your computer and use it in GitHub Desktop.
Save masak/201663 to your computer and use it in GitHub Desktop.
class Array is also {
multi method delete(@array is rw: *@indices) {
my @result;
for @indices -> $index {
my $i = $index >= 0
?? $index
!! * + $index;
@result.push(do { my $workaround = @array[$i] });
undefine @array[$i];
if $index == (@array - 1) | -1 {
@array.pop;
}
}
@array.pop while @array && !defined @array[* - 1];
return @result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment