Fwd: [november] Re: arrays and arrays ref question

2008-10-31 Thread Илья
So, I have found workaround for now: > my $ar = [1,2,3]; loop ( my $i = 0; $i < $ar.elems; $i++ ) { $ar[$i].say } 1 2 3 2008/10/30 Илья <[EMAIL PROTECTED]>: > I have found one: >> my $ar = [1,2,3]; my $i = 0; while $i < $ar.elems {say $ar[$i]; $i++ }; > 1 > 2 > 3 > > > 2008/10/30 Carl Mäsak <[EMA

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-31 Thread Guy Hulbert
On Fri, 2008-31-10 at 11:31 +0100, Carl Mäsak wrote: > >> > for @$ar { ... } > >> > or even > >> > for @ $ar { ... } > >> > or > >> > for @($ar) { ... } > > Guy (>): > > for ( @$ar ) { ... } > > > > ? > > That's Moritz' first suggestion, but with a pair of unnecessary > parentheses thrown in. :)

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-31 Thread Carl Mäsak
Guy (>), Carl (>>), Moritz (>>>): >> > for @($ar) { ... } >> >> This would arguably be the nicest variant. Well, actually, by "this" I meant all three variants that Moritz suggested. :) >> > for @$ar { ... } >> > or even >> > for @ $ar { ... } >> > or >> > for @($ar) { ... } Guy (>): > for ( @$a

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Guy Hulbert
On Thu, 2008-30-10 at 17:25 +0100, Carl Mäsak wrote: > > for @($ar) { ... } > > This would arguably be the nicest variant. for ( @$ar ) { ... } ? -- --gh

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Carl Mäsak
Moritz (>), Илья (>>): >> I have array ref >> my $ar = [1,2,3]; >> how can I go over it? > > Currently I think you can't, because the array contextualizer isn't > implemented yet. I think it should be > > for @$ar { ... } > or even > for @ $ar { ... } > or > for @($ar) { ... } This would arguably

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Moritz Lenz
Илья wrote: > Hi there, > question about arrays and array refs in Rakudo today. > > I have array ref > my $ar = [1,2,3]; > how can I go over it? Currently I think you can't, because the array contextualizer isn't implemented yet. I think it should be for @$ar { ... } or even for @ $ar { ... } or

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Carl Mäsak
Timothy (>): >>> my $r = <1 2 3>; for $r -> $t { say $t }; >> >> Which revision of Rakudo are you running? In my r32239, it outputs "1 >> 2 3" on the same line (i.e. it doesn't iterate over each element). > >Oops. My bad. Try either of the following with parrot 0.8.0. > > perl6 -e 'my $r

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Timothy S. Nelson
On Thu, 30 Oct 2008, Carl Mäsak wrote: Timothy (>): my $r = <1 2 3>; for $r -> $t { say $t }; Which revision of Rakudo are you running? In my r32239, it outputs "1 2 3" on the same line (i.e. it doesn't iterate over each element). Oops. My bad. Try either of the following with par

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Timothy S. Nelson
On Thu, 30 Oct 2008, wrote: Hi there, question about arrays and array refs in Rakudo today. I have array ref my $ar = [1,2,3]; how can I go over it? I try: my $r = [1,2,3]; say $r.elems; 3 my $r = [1,2,3]; say $r.WHAT; Array my $r = [1,2,3]; "Y".say for $r; Y my $r = [1,2,3]; .say

Re: Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Carl Mäsak
Timothy (>): > my $r = <1 2 3>; for $r -> $t { say $t }; Which revision of Rakudo are you running? In my r32239, it outputs "1 2 3" on the same line (i.e. it doesn't iterate over each element). // Carl

Fwd: [november] Re: arrays and arrays ref question

2008-10-30 Thread Илья
Hi there, question about arrays and array refs in Rakudo today. I have array ref my $ar = [1,2,3]; how can I go over it? I try: > my $r = [1,2,3]; say $r.elems; 3 > my $r = [1,2,3]; say $r.WHAT; Array > my $r = [1,2,3]; "Y".say for $r; Y > my $r = [1,2,3]; .say for $r; 1 2 3 #one string > my $r =