Re: Operating on pairs, Was Re: Revised solution #2

2009-01-16 Thread Richard Hainsworth
Carl Mäsak wrote: Andy (>): map? perl6 -e 'my $x = :a<5>; say $x.map( { .value / 10} ).fmt("%s")' Yes, sure. That'll print a tenth of the value of $x. The '.fmt("%s")' is a no-op in this case. // Carl Not entirely a no-op. Thus $perl6 > my $x=:a<5>; say $x.map({.value/10}).fmt("

Re: Operating on pairs, Was Re: Revised solution #2

2009-01-15 Thread Larry Wall
On Thu, Jan 15, 2009 at 12:46:09PM +0300, Richard Hainsworth wrote: > Larry Wall wrote: >> On Wed, Jan 14, 2009 at 09:55:38AM +0300, Richard Hainsworth wrote: >> >>> However, I came across one thing in solution #3 that I posted >>> yesterday. $pair.fmt("%s %s") is nice, but it doesnt allow for

Operating on pairs, Was Re: Revised solution #2

2009-01-15 Thread Richard Hainsworth
Larry Wall wrote: On Wed, Jan 14, 2009 at 09:55:38AM +0300, Richard Hainsworth wrote: However, I came across one thing in solution #3 that I posted yesterday. $pair.fmt("%s %s") is nice, but it doesnt allow for any action on either value or key before printing (I wanted to print the value

Re: Revised solution #2

2009-01-14 Thread Larry Wall
On Wed, Jan 14, 2009 at 09:55:38AM +0300, Richard Hainsworth wrote: > However, I came across one thing in solution #3 that I posted yesterday. > $pair.fmt("%s %s") is nice, but it doesnt allow for any action on either > value or key before printing (I wanted to print the value as a > percenta

Re: Revised solution #2

2009-01-13 Thread Carl Mäsak
Richard (>), Carl (>>), Andy (>>>): >>> P6 treats the key/value as an anonymous 'pair' object so @ranking is an >>> list of pairs. That's why: >>> say @ranking.pop.fmt("$m Medal: %s, %s") >>> >>> or, less succinctly: >>> say (pop @ranking).fmt("$m Medal: %s, %s"); >>> >>> works - the pair object,

Re: Revised solution #2

2009-01-13 Thread Richard Hainsworth
Carl Mäsak wrote: Andy (>): P6 treats the key/value as an anonymous 'pair' object so @ranking is an list of pairs. That's why: say @ranking.pop.fmt("$m Medal: %s, %s") or, less succinctly: say (pop @ranking).fmt("$m Medal: %s, %s"); works - the pair object, popped off into the 'printf' l

Revised solution #2

2009-01-12 Thread Richard Hainsworth
Of course whenever I post to this list I make some sort of mistake, like including a test version that does not parse in perl6. Hopefully, I have eliminated all the mistakes. The following is a revised version due to Carl Masak. The problem and model perl5 solution by Jan Dubois (a member of th