Re: Solution to Games #2

2009-01-11 Thread Larry Wall
On Sun, Jan 11, 2009 at 04:24:08PM +0300, Richard Hainsworth wrote: > my ($name,@list) = .split /\,/; That shouldn't parse, because .split should not be looking for an argument list. (And, in fact, STD rejects it.) You need one of: my ($name,@list) = .split: /\,/; my ($name,@list) = .

Re: not wanting something

2009-01-11 Thread Larry Wall
On Tue, Jan 06, 2009 at 04:41:30PM +0300, Richard Hainsworth wrote: > Supposed I define > > regex digit { [0..9] } > > what is the negative? You need to be careful about what you mean here by "negative". If you mean "match a single character that is not in the list", then it is as Patrick said.

Re: what is going on here?

2009-01-11 Thread Larry Wall
On Sat, Jan 10, 2009 at 11:26:50PM +0300, Richard Hainsworth wrote: > More precisely, I dont understand the meaning of the ':' after '.sort' It is turning the method call into a list operator, essentially. It's not the so-called indirect object syntax, or it would be written: my @ranking = so

Re: what is going on here?

2009-01-11 Thread Moritz Lenz
Richard Hainsworth wrote: > Could someone help me understand what is going on in the following snippet? > > my %players = {'william'=>2, 'peter'=>3,'john'=>1,'mary'=>5}; > my @ranking = %players.sort: { .value }; > for @ranking {.say}; > > I cut and pasted from Patrick's blog on sorting and playe

Re: Solution to Games #2

2009-01-11 Thread Carl Mäsak
Richard (>): > use v6; > > my %players; > my $scores = open('./skaters.txt', :r) or die $!; > for =$scores { > my ($name,@list) = .split /\,/; > %players{$name} = ([+] @list.sort[2..6]) / 5; > }; > > my @ranking = %players.sort: { .value }; > for -> $m { > given pop @ranking { > say "$m Me

Solution to Games #2

2009-01-11 Thread Richard Hainsworth
Here's a solution to Scripting Games #2. Script and data file attached. The algorithm closely follows the published solution by the perl expert. Here is the model solution use 5.010; use strict; use warnings; use List::Util qw(sum); my %score; open(my $fh, "<", "C:/Scripts/skaters.txt") or die

Re: what is going on here?

2009-01-11 Thread Илья
Hi! > More precisely, I dont understand the meaning of the ':' after '.sort' see line 1825 of S03 C<< infix:<:>>>, the invocant maker ... ack (or grep) ': {}' in Spec dir can give a lot of examples. ihrd

Re: what is going on here?

2009-01-11 Thread Hal Wigoda
the first line creates a hash, the second line sorts the hash values into an array. the third loops thru the array values printing one array member per line On Jan 10, 2009, at 2:26 PM, Richard Hainsworth wrote: Could someone help me understand what is going on in the following snippet? my %p

Re: [Fwd: [Fwd: Re: what is going on here?]]

2009-01-11 Thread Brandon S. Allbery KF8NH
On 2009 Jan 11, at 3:50, Richard Hainsworth wrote: To be precise - why the ':' after the sort? '%players.sort' calls the 'sort' method/sub on the hash '%players'. '{.value}' runs '.value' on $_ at some point. But when? So once again, what is the ':' doing? How else could this code be writt

[Fwd: [Fwd: Re: what is going on here?]]

2009-01-11 Thread Richard Hainsworth
thanks for the response, but i was really looking for a bit more detail. To be precise - why the ':' after the sort? '%players.sort' calls the 'sort' method/sub on the hash '%players'. '{.value}' runs '.value' on $_ at some point. But when? So once again, what is the ':' doing? How else could