Skip to content

New named parameters to .classify #6

Open
@FCO

Description

@FCO

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    RSC ReviewThis issue will be reviewed by the RSC and decided upon soonlanguageChanges to the Raku Programming Language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions