Dear Timo.
So .categorize and .classify wil always end with list on leaves of
produced tree? Ok I can live with that :)
On Sat, Jun 14, 2014 at 12:30 PM, wrote:
> Dear Kamil,
>
>
> On 06/13/2014 10:24 PM, Kamil Kułaga wrote:
>> my %h = categorize({map {[.a , .b]}, $_},@array);
>
> I think the p
Dear Kamil,
On 06/13/2014 10:24 PM, Kamil Kułaga wrote:
> my %h = categorize({map {[.a , .b]}, $_},@array);
I think the problem is that categorize will call your inner code block
for every item in the @array. Then you map your {[.a, .b]} over that
item, so you end up with a single-item list as a
Dear Timo,
I'm almost done with categorize. I stole similar example from rakudo
tests but I can't get rid off array on end. If I remove from map []
it stops working.
PS. I barely understand code I wrote anyway :)
$ perl6 ~/xx.pl
[A.new(a => "a", b => "22")]
Reference
A.new(a => "a", b => "
On 13 Jun 2014, at 12:36, Kamil Kułaga wrote:
> I was wondering whether following code can be rewritten using map/grep
> construct.
>
>
>class A {
> has $.a;
> has $.b;
> }
>
>
> my @array= (
> A.new(a=>'a', b=>'11'),
> A.new(a=>'a', b=>'22'),
> A.new(a=>'v', b=>'33')
On 06/13/2014 08:15 PM, Kamil Kułaga wrote:
> Ok got it. But solution is neither more readable nor faster (IMHO only
> -> I didn't benchmark it)
>
>
> class A { has $.a; has $.b };
> my @array = A.new(a=>'a', b=>'11'),
> A.new(a=>'a', b=>'22'),
> A.new(a=>'v', b=>'33'),
> A.new(a=>'w',
Ok got it. But solution is neither more readable nor faster (IMHO only
-> I didn't benchmark it)
class A { has $.a; has $.b };
my @array = A.new(a=>'a', b=>'11'),
A.new(a=>'a', b=>'22'),
A.new(a=>'v', b=>'33'),
A.new(a=>'w', b=>'44'),
A.new(a=>'v', b=>'55');
my %h = @array.map({
Hi Tobias,
Almost. At least at my rakudo creates list of hash of hash and loses
data while converting to hash:
("a" => "11" => A.new(a => "a", b => "11"), "a" => "22" => A.new(a =>
"a", b => "22"), "v" => "33" => A.new(a => "v", b => "33"), "w" =>
"44" => A.new(a => "w", b => "44"), "v" => "55" =
Hi, like that?
class A { has $.a; has $.b };
my @array = A.new(a=>'a', b=>'11'),
A.new(a=>'a', b=>'22'),
A.new(a=>'v', b=>'33'),
A.new(a=>'w', b=>'44'),
A.new(a=>'v', b=>'55');
say @array.map({ .a => .b => $_ })
OUTPUT«"a" => "11" => A.new(a => "a"
Hi,
I was wondering whether following code can be rewritten using map/grep
construct.
class A {
has $.a;
has $.b;
}
my @array= (
A.new(a=>'a', b=>'11'),
A.new(a=>'a', b=>'22'),
A.new(a=>'v', b=>'33'),
A.new(a=>'w', b=>'44'),
A.new(a=>'v', b=>'55')
);