(collection: Iterable<bigint>): bigintTakes an Iterable of bigints and returns their sum as a single bigint. Returns 0n for an empty iterable.
When to use
Use when you want an immediate aggregate from an iterable instead of a folding reducer owned by another API.
Example (Summing iterable bigints)
import { BigInt } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigInt.sumAll([2n, 3n, 4n]), 9n)Source effect/BigInt.ts:7697 lines
export const const sumAll: (
collection: Iterable<bigint>
) => bigint
Takes an Iterable of bigints and returns their sum as a single bigint. Returns 0n for an empty iterable.
When to use
Use when you want an immediate aggregate from an iterable instead of a
folding reducer owned by another API.
Example (Summing iterable bigints)
import { BigInt } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigInt.sumAll([2n, 3n, 4n]), 9n)
sumAll = (collection: Iterable<bigint>collection: interface Iterable<T, TReturn = any, TNext = any>Iterable<bigint>): bigint => {
let let out: bigintout = const bigint0: bigintbigint0
for (const const n: bigintn of collection: Iterable<bigint>collection) {
let out: bigintout += const n: bigintn
}
return let out: bigintout
}