»
group_reduce
Sequence.group_reduce
(K
type
:
property.orderable, key_f Unary K Sequence.T, reduce_f Binary Sequence.T Sequence.T Sequence.T) =>
container.Map K Sequence.T[Contains abstract features]
¶Type Parameters
type of the keys
0.094dev (2025-06-18 15:08:51 GIT hash 89cffc23ae669b0898a5564fefbf793fcb8e5ca7 built by fridi@fzen)
in contrast to the more general version, values in the resulting map must have the same type as in the input
example: sum even and odd numbers individually
(0..10).group_reduce String (x -> x%%2 ? "even" : "odd") (+)
=> {(even => 30), (odd => 25)}