Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add ...^ operator
  • Loading branch information
patrickas authored and moritz committed Sep 6, 2010
1 parent 77a72a3 commit b736c88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -1910,6 +1910,7 @@ token infix:sym<Z> { <!before <sym> <infixish> > <sym> <O('%list_infix')> }
token infix:sym<X> { <!before <sym> <infixish> > <sym> <O('%list_infix')> }

token infix:sym<...> { <sym> <O('%list_infix')> }
token infix:sym<...^> { <sym> <O('%list_infix')> }
# token term:sym<...> { <sym> <args>? <O(|%list_prefix)> }

token infix:sym<=> {
Expand Down
13 changes: 13 additions & 0 deletions src/core/operators.pm
Expand Up @@ -450,6 +450,19 @@ our multi sub infix:<...>(@lhs, @rhs is copy) {
(@lhs ... @rhs.shift), @rhs
}

our multi sub infix:<...^>($lhs, $rhs) {
my @all := ($lhs ... $rhs);
return Nil unless defined @all[0];
gather {
loop {
last unless defined @all[0];
my $current = @all.shift() ;
last if $current eqv $rhs ;
take $current;
}
}
}

our multi sub infix:<eqv>(Mu $a, Mu $b) {
$a.WHAT === $b.WHAT && $a === $b;
}
Expand Down

0 comments on commit b736c88

Please sign in to comment.