Navigation Menu

Skip to content

Commit

Permalink
Make sure [3,*-3]:delete works
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Sep 30, 2013
1 parent ccf9c47 commit 3090ed4
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/core/array_slice.pm
Expand Up @@ -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( {
Expand Down Expand Up @@ -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[*]
Expand Down

0 comments on commit 3090ed4

Please sign in to comment.