> On Nov 22, 2019, at 9:57 AM, Marc Chantreux <e...@phear.org> wrote:
> 
> On Fri, Nov 22, 2019 at 06:20:51AM -0800, William Michels via perl6-users 
> wrote:
>> Hi Marc, I did a search for 'semicolon' on the following page and
>> found the interesting text below. Semicolons are used to create
>> multidimensional lists, maybe that's what's going on in your code?
> 
> indeed! i tried with ";" but it wasn't that helpful. :)
> 
>> PS I would presume some variation of 'next' would work where you're
>> using 'walkTheHash', but I don't really know for sure.
> 
> Gianni gave the solution: my script became:
> 
>    fix () perl6 -e '
>        my %section;
>        lines.map: {postcircumfix:<{; }>( %section, .split(",") ) = 1 };
>        %section.keys.map: { .say for $_ , |%section{$_}.keys.map: {"\t$_"} }
>    '
> 
> it would be nice to have a shorter syntax to access to access to
> postcircumfix:<{; }> but still: it's awesome.
> 
> regards
> 
> marc

FWIW, I would make %section an HoA, which would be a less compact structure in 
memory, but allows more succinct manipulation, like so:
my %section = lines()
             .map( *.split(",") )
             .classify( { .[0] }, :as{ .[1] } );

for %section.sort {
    say .key;
    say "\t$_" for .value.sort.unique;
}

Reply via email to