Skip to content

Commit ad211f6

Browse files
authored
+ sumBy
1 parent 3228a09 commit ad211f6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/FSharpPlus/Operators.fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,13 @@ module Operators =
16071607
/// <category index="23">Additional Functions</category>
16081608
let inline sum (x: '``Foldable<'Monoid>``) : 'Monoid = fold (++) (getZero () : 'Monoid) x
16091609

1610+
/// <summary>
1611+
/// Folds the sum of all monoid elements in the Foldable resulting of applying the projection.
1612+
/// </summary>
1613+
/// <category index="23">Additional Functions</category>
1614+
let inline sumBy ([<InlineIfLambda>] projection: 'T -> 'Monoid) (x: '``FoldableFunctor<'T>``) : 'Monoid =
1615+
fold (++) (getZero () : 'Monoid) (map projection x)
1616+
16101617
/// <summary>
16111618
/// Converts using the implicit operator.
16121619
/// </summary>

0 commit comments

Comments
 (0)