Skip to content

Commit

Permalink
More correctly implement ^... and ^...^
Browse files Browse the repository at this point in the history
At least for now: problems found while writing tests for ^... and
^...^ .  Main problems is that the simplification of just removing
the last value generated, does not work with ... if the RHS is a
list: then the value that should be skipped (or not) is the first
value of that list, *not* the last value of that list.
  • Loading branch information
lizmat committed Apr 4, 2020
1 parent 2cbf583 commit bbed225
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core.c/operators.pm6
Expand Up @@ -179,18 +179,22 @@ multi sub infix:<...^>(\a, Mu \b) {
my constant &infix:<…^> := &infix:<...^>;

proto sub infix:<^...>(|) {*}
multi sub infix:<^...>(|c) {
Seq.new: Rakudo::Iterator.AllButFirst(infix:<...>(|c).iterator)
multi sub infix:<^...>(\a, Mu \b) {
Seq.new: Rakudo::Iterator.AllButFirst(SEQUENCE(a, b))
}
multi sub infix:<^...>(|lol) {
Seq.new: Rakudo::Iterator.AllButFirst(infix:<...>(|lol).iterator)
}

# U+005E CIRCUMFLEX ACCENT, U+2026 HORIZONTAL ELLIPSIS
my constant &infix:<^…> := &infix:<^...>;

proto sub infix:<^...^>(|) {*}
multi sub infix:<^...^>(|c) {
Seq.new: Rakudo::Iterator.AllButLast(
Rakudo::Iterator.AllButFirst(infix:<...>(|c).iterator)
)
multi sub infix:<^...^>(\a, Mu \b) {
Seq.new: Rakudo::Iterator.AllButFirst(SEQUENCE(a, b, :exclude_end))
}
multi sub infix:<^...^>(|lol) {
Seq.new: Rakudo::Iterator.AllButFirst(infix:<...>(|lol).iterator) # XXX
}

# U+005E CIRCUMFLEX ACCENT, U+2026 HORIZONTAL ELLIPSIS, U+005E CIRCUMFLEX ACCENT
Expand Down

0 comments on commit bbed225

Please sign in to comment.