diff --git a/src/FSharpAux.Core/ResizeArray.fs b/src/FSharpAux.Core/ResizeArray.fs index 17c5d2e..3543e70 100644 --- a/src/FSharpAux.Core/ResizeArray.fs +++ b/src/FSharpAux.Core/ResizeArray.fs @@ -402,6 +402,9 @@ module ResizeArray = accv <- currv accv +/// Sums all the values in the . + /// The input ResizeArray. + /// The resulting sum. let inline sum (array: ResizeArray< ^T>) = checkNonNull "array" array let mutable acc = LanguagePrimitives.GenericZero< ^T> @@ -409,6 +412,10 @@ module ResizeArray = acc <- Checked.(+) acc array.[i] acc + /// Returns the sum of the results generated by applying the function () to each element of the . + /// The function to transform the ResizeArray elements into the type to be summed. + /// The input ResizeArray. + /// The resulting sum. let inline sumBy ([] projection: 'T -> ^R) (array: ResizeArray<'T>) = checkNonNull "array" array let mutable acc = LanguagePrimitives.GenericZero< ^R> @@ -416,9 +423,13 @@ module ResizeArray = acc <- Checked.(+) acc (projection array.[i]) acc - let countIf (projection: 'T -> bool) (arr: ResizeArray<'T>): int = + /// Counts the number of elements in the satisfying the . + /// The function to transform the ResizeArray elements into the type to be summed. + /// The input ResizeArray. + /// Number of elements satisfying the . + let countIf (predicate: 'T -> bool) (arr: ResizeArray<'T>): int = let mutable acc = 0 for i=0 to arr.Count - 1 do - if projection arr.[i] then + if predicate arr.[i] then acc <- acc + 1 acc \ No newline at end of file