kcl-stdfunctionsreduce

reduceFunction in std::array

Take a starting value. Then, for each element of an array, calculate the next value, using the previous value and the element.

Arguments

NameTypeDescriptionRequired
array[any]Each element of this array gets run through the function f, combined with the previous output from f, and then used for the next run.Yes
initialanyThe first time f is run, it will be called with the first item of array and this initial starting value.Yes
ffn(any, accum: any): anyRun once per item in the input array. This function takes an item from the array, and the previous output from f (or initial on the very first run). The final time f is run, its output is returned as the final output from reduce.Yes

Returns

any - The any type is the type of all possible values in KCL. I.e., if a function accepts an argument with type any, then it can accept any value.

Examples

Found a typo?