The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Message from discussion Aliasing an array slice

From:
To:
Cc:
Followup To:
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Jul 18 2003, 8:00 pm
Newsgroups: perl.perl6.language
From: fibon...@babylonia.flatirons.org (Luke Palmer)
Date: 18 Jul 2003 17:51:51 -0600
Local: Fri, Jul 18 2003 7:51 pm
Subject: Re: Aliasing an array slice

> David Storrs wrote:

> > Thinking about it, I'd rather see lvalue slices become a nicer version
> > of C<splice()>.

> >      my @start = (0..5);
> >      my @a = @start;

> >      @a[1..3] = qw/ a b c d e /;
> >      print @a;   #  0 a b c d e 4 5

> What would happen if I used 1,2,3 instead of 1..3?  Would it do the same
> thing?

Of course.

> I wanna know what happens if I do:

>        @a[0,2,4] = qw/ a b c d e /;

It would probably do the same as in Perl 5; the same thing as:

@a[0,2,4] = << a b c >>;

(those << >> brackets are new shorthand for qw, not that qw is going
anywhere)

Luke

> --
> \$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
> );{push(@b,\$a),(\$a-=6)^=1 for 2..\$a/6x--\$|;print "\$@[\$a%6
> ]\n";((6<=(\$a-=6))?\$a+=\$_[\$a%6]-\$a%6:(\$a=pop @b))&&redo;}