problem-solving
problem-solving copied to clipboard
New named parameters to .classify
Id like to suggest to add:
-
:&reduce -
:&produce -
:$initial-value
so,
^10.classify: * %% 2, :reduce(&[+])
would return
{True => 25, False => 20}
,
^10.classify: * %% 2, :produce(&[+])
would return
({}, {True => 0}, {True => 0, False => 1}, {True => 2, False => 1}, {True => 2, False => 4}, {True => 6, False => 4}, {True => 6, False => 9}, {True => 12, False => 9}, {True => 12, False => 16}, {True => 20, False => 16}, {True => 20, False => 25}).Seq
and
^5.classify: * %% 2, :produce(-> %agg, $i { %agg{$i} = <a e i o u>[$i]; %agg }), :initial-value{}
would return
{True => {0 => "a", 2 => "I", 4 => "u"}, False => {1 => "e", 3 => "o"}}
That would also be interesting to add the :$initial-value (or with any name) to .reduce and .produce