On 01/26/2018 01:51 PM, Brandon Allbery wrote:
You probably want an enum to get that behavior. Strings are strings;
Perl has no idea what they mean.
Larry is a cleaver guy, so I was pushing the envelope!
:-)
You probably want an enum to get that behavior. Strings are strings; Perl
has no idea what they mean.
On Fri, Jan 26, 2018 at 4:45 PM, ToddAndMargo wrote:
> Sweet!
> $ perl6 -e 'my $x=(1...5...1); say $x;'
> (1 2 3 4 5 4 3 2 1)
>
> Characters too!
> $ perl6 -e 'my $x=("a"..."f"..."a"); say $x;'
Sweet!
$ perl6 -e 'my $x=(1...5...1); say $x;'
(1 2 3 4 5 4 3 2 1)
Characters too!
$ perl6 -e 'my $x=("a"..."f"..."a"); say $x;'
(a b c d e f e d c b a)
Ah Shucks (ah poop)!
$ perl6 -e 'my $x=("Monday"..."Friday"); say $x;'
(Monday Momday Molday Mokday Mojday Moiday Mpnday Mpmday Mplday Mpkday
The most detailed description of ... is still to be found starting down a few
paragraphs in the https://design.perl6.org/S03.html#List_infix_precedence
section.
In general the operators have not suffered as much "spec rot" as some other
parts
of the "speculations" known as Synopses, so most of S0
Today I stumbled across the fact that the sequence operator can be chained:
> 1...5...1
(1 2 3 4 5 4 3 2 1)
You can even reduce with it:
> [...] 1, 5, 3, 10, 8
(1 2 3 4 5 4 3 4 5 6 7 8 9 10 9 8)
And even sequences with custom generators can be joined:
> 0,1,*+*...144,*/2...9
(0 1 1 2 3 5 8 13
This works now (same output on Moar, Parrot and JVM):
$ perl6 -e 'say 1, *+1 ... { $_ == 9 }, 10, *+10 ... { $_ == 90 }, 100, *+100
... { $_ == 900 }'
1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 200 300 400 500 600 700 800 900
$ perl6 -e 'say 1, 2 ... 4, 6 ... 10, 12'
1 2 3 4 6 8 10 12
$ p
I added tests for this ticket to S03-sequence/misc.t with commit
https://github.com/perl6/roast/commit/1db2856082
# New Ticket Created by Christian Bartolomaeus
# Please include the string: [perl #123329]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=123329 >
According to S03 it is possible to chain sequence operators. There are some
te