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
Weirdness when mixing ..
and ...
without parens
#6021
Comments
From @smlsWhen the operators `..` and `...` are used in the same comma-separated ➜ say 1..2,7,5...2; ➜ say 1..1,7,5...2; ➜ say 1,7,5...2; Of those examples, the only one that outputs what I expected, is the third one. |
From @AlexDanielIt numifies ranges so that the number of elements is used. In other words, 1..2 works like 2 and 1..1 works like 1. It looks like it hurts when you do this… On 2017-01-20 07:29:03, smls75@gmail.com wrote:
|
The RT System itself - Status changed from 'new' to 'open' |
From @smls
No, if it worked like that then the first two examples would throw the same error as the third, instead of exhibiting behaviors that are both different from that and from each other. Here are two more examples, showing the difference in case of an actual arithmetic series: ➜ say 1..1, 3 ... 7; ➜ say 1, 3 ... 7; |
From @smlsThis bug is still present in Rakudo version 2017.08-8-g753c9a5ea built on MoarVM version 2017.08.1-19-g151a2563 |
From @AlexDanielIndeed, I'm not sure what I was smoking.
|
From @AlexDanielOh. Maybe it's https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127279 ? On 2017-08-26 08:01:06, alex.jakimenko@gmail.com wrote:
|
From @skidsOn Mon, 02 Oct 2017 00:26:27 -0700, alex.jakimenko@gmail.com wrote:
This may be operating as designed. First, note that in ..., you are not guaranteed that all the elements in the first list are returned: $ perl6 -e 'say 1,2,3,4...3' ...as soon as the 3 on the lhs matches the 3 on the rhs, the sequence terminates. And yes, some of this is due to ranges collapsing to +.elems. The comparison to $ perl6 -e 'say (4..7) ~~ 4' ..only a 4-element list smartmatches 4. So for the above examples here is what is happening: 1..2,7,5...2; # 1..2 matches 2. Emit it and stop. 1..1,7,5...2; # nothing matches the 2. So we follow the spec... So we skip doing this: "That is, supposing we call the last three numbers C<$a>, C<$b>, and $ab = $b - $a; If C<$ab == $bc> and C<$ab> is not zero, then we deduce an arithmetic ...and we do this instead: "If they do not look like numbers, then the function selected is either ...$b is 7 and $c is 5, so we call .pred on 5 until we get a result that matches 2. 1,7,5...2; # We have three actual trailing numbers and should be able to deduce a pattern, but cannot. |
Migrated from rt.perl.org#130604 (status was 'open')
Searchable as RT130604$
The text was updated successfully, but these errors were encountered: