It looks like it works if you call the .Seq method on a scalar $index :
> my @array = 9 ... 0
[9 8 7 6 5 4 3 2 1 0]
> my $index = map { $_, $_ + 1 }, ^9
((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9))
> say @array[$index.Seq]
((9 8) (8 7) (7 6) (6 5) (5 4) (4 3) (3 2) (2 1) (1 0))
> put @array[$index.Seq]
9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 0
>
HTH, Bill.
On Fri, Aug 16, 2019 at 4:25 AM Elizabeth Mattijsen <[email protected]> wrote:
>
> Feels like worthy of making an issue for this to me.
>
> > On 16 Aug 2019, at 12:18, Sean McAfee <[email protected]> wrote:
> >
> > Today I was surprised and pleased to find that I could apparently subscript
> > an array with a list of lists of indices, and get a list of slices back:
> >
> > > my @array = 9 ... 0
> > [9 8 7 6 5 4 3 2 1 0]
> > > @array[map { $_, $_ + 1 }, ^9]
> > ((9 8) (8 7) (7 6) (6 5) (5 4) (4 3) (3 2) (2 1) (1 0))
> >
> > Neat! But when I tried to clean up my code a bit, it broke.
> >
> > > my @index = map { $_, $_ + 1 }, ^9
> > [(0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9)]
> > > @array[@index]
> > (7 7 7 7 7 7 7 7 7)
> >
> > Weird. But map returns a Seq, right? So maybe...
> >
> > > @array[@index.Seq]
> > (7 7 7 7 7 7 7 7 7)
> >
> > Hmm. How about:
> >
> > > @array[@index.List]
> > ((9 8) (8 7) (7 6) (6 5) (5 4) (4 3) (3 2) (2 1) (1 0))
> >
> > That works again. But why? Is this the intended behavior? If so, is it
> > documented somwhere?
> >