Athanasius has asked for the wisdom of the Perl Monks concerning the following question:
In Perl, a range within an array slice behaves as though the individual elements in the range had been specified with comma separators:
11:44 >perl -MData::Dump -we "my @c = 'a'..'z'; dd map { qq[<$_>] } @c +[6..9, 23, 25];" ("<g>", "<h>", "<i>", "<j>", "<x>", "<z>") 11:45 >
This is what I would expect. But in Raku, it seems that a range inside an array slice produces an additional layer of grouping:
11:45 >raku -v This is Rakudo version 2020.05.1 built on MoarVM version 2020.05 implementing Raku 6.d. 11:45 >raku -e "my @c = 'a'..'z'; @c[6..9, 23, 25].map( { qq[<$_>] } ) +.raku.put;" ("<g h i j>", "<x>", "<z>").Seq 11:46 >
AFAICT, the Raku documentation on subscripts doesn’t explain this. So, I have two questions:
Thanks,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: [Raku] Ranges in array slices
by holli (Abbot) on Jun 01, 2021 at 05:47 UTC | |
by Athanasius (Archbishop) on Jun 01, 2021 at 06:26 UTC | |
Re: [Raku] Ranges in array slices
by tomasz (Acolyte) on Jun 05, 2021 at 05:25 UTC | |
by Athanasius (Archbishop) on Jun 05, 2021 at 14:24 UTC | |
by holli (Abbot) on Jun 05, 2021 at 19:14 UTC | |
by tomasz (Acolyte) on Jun 05, 2021 at 16:11 UTC | |
by holli (Abbot) on Jun 05, 2021 at 19:20 UTC | |
by tomasz (Acolyte) on Jun 05, 2021 at 20:46 UTC | |
| |
by tomasz (Acolyte) on Jun 06, 2021 at 11:40 UTC | |
|