New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make 4 ... 0, 1, 2, 3, 4 (an infix:<...> with a list to the right) do the right thing in Rakudo #1825
Comments
From @masak<moritz_> rakudo: say (4...^5).perl Expected output from both these are, IIUC, (4, 3, 2, 1, 0, 1, 2, 3, 4). |
From dimid@no-more.kiev.uafix for this bug into attach |
From dimid@no-more.kiev.ua0001-fix-an-infix-.-with-a-list-to-the-right-do-right-thi.patchFrom a08ad0ed8c8dad01f0ceb39f4d84acbfea6c373e Mon Sep 17 00:00:00 2001
From: Alexey Grebenschikov <dimid@no-more.kiev.ua>
Date: Sat, 12 Jun 2010 18:13:01 +0300
Subject: [PATCH] fix: an infix:<...> with a list to the right do right thing
---
src/core/operators.pm | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/core/operators.pm b/src/core/operators.pm
index ecdd356..0f984ea 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -345,6 +345,12 @@ our multi sub infix:<...>($lhs, $rhs) {
take $y;
}
}
+
+ if $rhs ~~ Iterable {
+ for @($rhs) {
+ take $_;
+ }
+ }
}
}
--
1.7.1
|
From @jnthnOn Sat Jun 12 08:16:42 2010, dimid wrote:
Patch applied, awaiting test coverage. Jonathan |
@jnthn - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/series.t commit dc653c9531fffc0b0f7ed4ab68cac68200687c53 [t/spec] Add tests for RT#75674. infix:<...> works with a list to the right Inline Patchdiff --git a/t/spec/S03-operators/series.t b/t/spec/S03-operators/series.t
index 0123cb6..c0d7d82 100644
--- a/t/spec/S03-operators/series.t
+++ b/t/spec/S03-operators/series.t
@@ -145,6 +145,11 @@ is (16, 8, 4 ... *).batch(5).join(', '), '16, 8, 4, 2, 1', 'geom decreasing';
'expression with two magic series operators and non-matching end points';
}
+{
+ is ~(4 ... ^5), ~<4 3 2 1 0 1 2 3 4>, '4 ... ^5 works';
+ is ~(4 ... 0, 1, 2, 3, 4), ~<4 3 2 1 0 1 2 3 4>, '4 ... 0, 1, 2, 3,4 works';
+}
+
done_testing;
# vim: ft=perl6 |
From justin.sahs@gmail.comOn Sat Jun 12 08:35:16 2010, jnthn@jnthn.net wrote:
The applied patch works when the lhs is a single integer, e.g. (-5 ... |
From justin.sahs@gmail.comfix.patchdiff --git a/src/core/operators.pm b/src/core/operators.pm
index 0f984ea..10fd569 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -491,6 +491,12 @@ our multi sub infix:<...>(@lhs is copy, $rhs) {
}
}
}
+
+ if $rhs ~~ Iterable {
+ for @($rhs) {
+ take $_;
+ }
+ }
}
}
|
From justin.sahs@gmail.comIgnore my previous: didn't notice a repeated element. For clarity: After my (new) patch: |
From justin.sahs@gmail.comfix2.patchdiff --git a/src/core/operators.pm b/src/core/operators.pm
index 0f984ea..c09e752 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -347,7 +347,12 @@ our multi sub infix:<...>($lhs, $rhs) {
}
if $rhs ~~ Iterable {
- for @($rhs) {
+ my @rest = @($rhs);
+ # 1 cmp 1,2,3 == -1, rather than 0,
+ # so if $lhs cmp $rhs == -1, the first element
+ # of @rest has already been taken
+ @rest.shift if $lhs cmp $rhs == -1;
+ for @rest {
take $_;
}
}
@@ -491,6 +496,15 @@ our multi sub infix:<...>(@lhs is copy, $rhs) {
}
}
}
+
+ if $rhs ~~ Iterable {
+ my @rest = @($rhs);
+ # the first element has already been taken
+ @rest.shift;
+ for @rest {
+ take $_;
+ }
+ }
}
}
|
From @cokeOn Sat Jun 12 08:35:16 2010, jnthn@jnthn.net wrote:
Tests added to S03-sequence/basic.t (with minor whitespace tweak from TimToady++); -- |
@coke - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#75674 (status was 'resolved')
Searchable as RT75674$
The text was updated successfully, but these errors were encountered: