import { reduce } from "https://deno.land/x/fun@v2.0.0-alpha.6/array.ts";
Reduce an array from left to right, accumulating into a type O via the function foao: (O, A, index) => O and an initial value O.
Examples
Example 1
Example 1
import * as A from "./array.ts";
import { pipe } from "./fn.ts";
const result = pipe(
A.range(5, 1),
A.reduce((sum, value, index) => sum + value + index, 0),
);
// 0 + 0 + 0 = 0
// 0 + 1 + 1 = 2
// 2 + 2 + 2 = 6
// 6 + 3 + 3 = 12
// 12 + 4 + 4 = 20
// 20