[S29] update (was: Re: Question about $pair.kv)
Hi, Luke Palmer luqui.org> writes: > Stevan Little writes: > > One tests shows $pair.kv returning an array with two elements (the key > > and value of the pair). (This is also how Pugs currently implements > > this.) > > The former is certainly correct. When all else fails, consider a pair > to be a one-element hash. then the S29 draft (http://www.rodadams.net/Perl/S29.html) needs updating, as currently it states: > What is returned at each element of the iteration varies > with function. values returns the value of the associated > element; **kv returns a 2 element list in (index, value) > order**, pairs a Pair(index, value). Unless, of course, I misunderstand any(S29, Luke) :) -- Is the following correct? my @array = ; my @kv= @array.kv; say [EMAIL PROTECTED]; # 6 say [EMAIL PROTECTED]; # 0 a 1 b 2 c FYI, before your post, my assumption was: my @array = ; my @kv= @array.kv; say [EMAIL PROTECTED]; # 3 say [EMAIL PROTECTED]; # 0 a say [EMAIL PROTECTED]; # 1 b say [EMAIL PROTECTED]; # 2 c # That means, @kv = ([0, a], [1, b], [2, c]) --Ingo -- Linux, the choice of a GNU | Life would be so much easier if we could generation on a dual AMD | just look at the source code. Athlon!| -- Dave Olson
Re: Question about $pair.kv
Stevan Little writes: > One tests shows $pair.kv returning an array with two elements (the key > and value of the pair). (This is also how Pugs currently implements > this.) > > Another test shows $pair.kv returning an array with one element which > is an array-ref/list which itself has 2 elements (the key and value) in > it. > > I tend to think the former is correct, however a comment over the later > one indicated that it was stated to be this way on this list. I looked > though the list, but was unable to find the specific reference. The former is certainly correct. When all else fails, consider a pair to be a one-element hash. Luke
Re: Question about $pair.kv
--- Stevan Little <[EMAIL PROTECTED]> wrote: > Autrijus asked me to look into the correct behavior for $pair.kv > One tests shows $pair.kv returning an array with two elements (the > key > and value of the pair). (This is also how Pugs currently implements > this.) > > Another test shows $pair.kv returning an array with one element which > > is an array-ref/list which itself has 2 elements (the key and value) > in it. Page 52 of the 2nd Edition Perl6 and Parrot has this: for %ages.kv -> $name, $age { print "$name is now $age"; } That tends to suggest the former interpretation is correct. Cheers, Ovid -- If this message is a response to a question on a mailing list, please send follow up questions to the list. Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/