Hyperlinkv0.8.0-beta.28

BigInt

BigInt.multiplyAllconsteffect/BigInt.ts:799
(collection: Iterable<bigint>): bigint

Takes an Iterable of bigints and returns their product as a single bigint. Returns 1n for an empty iterable.

When to use

Use to multiply all bigint values in an iterable.

Example (Multiplying iterable bigints)

import { BigInt } from "effect"
import * as assert from "node:assert"

assert.deepStrictEqual(BigInt.multiplyAll([2n, 3n, 4n]), 24n)
Source effect/BigInt.ts:79910 lines
export const multiplyAll = (collection: Iterable<bigint>): bigint => {
  let out = bigint1
  for (const n of collection) {
    if (n === bigint0) {
      return bigint0
    }
    out *= n
  }
  return out
}