Permalink
Browse files

Make sure [3,*-3]:delete works

  • Loading branch information...
1 parent ccf9c47 commit 3090ed4a21392357521d3c0abc6a1d91db2f0708 @lizmat lizmat committed Sep 30, 2013
Showing with 9 additions and 13 deletions.
  1. +9 −13 src/core/array_slice.pm
View
@@ -3,7 +3,9 @@
sub POSITIONS (\SELF, \pos) { # handle possible infinite slices
my $positions = pos.flat;
$positions.gimme(*);
- return $positions.eager.Parcel unless $positions.infinite;
+ return $positions.map( {
+ $_ ~~ Callable ?? $_(|(SELF.elems xx $_.count)) !! $_
+ } ).eager.Parcel unless $positions.infinite;
my $list = SELF.list;
$positions.map( {
@@ -110,28 +112,22 @@ multi sub postcircumfix:<[ ]>(\SELF, Callable $block, :$BIND!) is rw {
X::Bind::Slice.new(type => SELF.WHAT).throw;
}
multi sub postcircumfix:<[ ]>(\SELF,Callable $block,:$delete!,*%other) is rw {
- SLICE_MORE( SELF, $block(|(SELF.elems xx $block.count)),
- True, :$delete, |%other );
+ SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$delete, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF,Callable $block,:$exists!,*%other) is rw {
- SLICE_MORE( SELF, $block(|(SELF.elems xx $block.count)),
- True, :$exists, |%other );
+ SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$exists, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable $block, :$kv!, *%other) is rw {
- SLICE_MORE( SELF, $block(|(SELF.elems xx $block.count)),
- True, :$kv, |%other );
+ SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$kv, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable $block, :$p!, *%other) is rw {
- SLICE_MORE( SELF, $block(|(SELF.elems xx $block.count)),
- True, :$p, |%other );
+ SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$p, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable $block, :$k!, *%other) is rw {
- SLICE_MORE( SELF, $block(|(SELF.elems xx $block.count)),
- True, :$k, |%other );
+ SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$k, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable $block, :$v!, *%other) is rw {
- SLICE_MORE( SELF, $block(|(SELF.elems xx $block.count)),
- True, :$v, |%other );
+ SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$v, |%other );
}
# @a[*]

0 comments on commit 3090ed4

Please sign in to comment.