From bbed2255f3cb71597bf4ca59eeadf57a610abb8f Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Sat, 4 Apr 2020 11:22:55 +0200 Subject: [PATCH] More correctly implement ^... and ^...^ 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. --- src/core.c/operators.pm6 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core.c/operators.pm6 b/src/core.c/operators.pm6 index 9fa7ee7e9b0..624de0c77fd 100644 --- a/src/core.c/operators.pm6 +++ b/src/core.c/operators.pm6 @@ -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