effect-io-ai

Package: effect
Module: Iterable

Iterable.makeBy

Return a Iterable with element i initialized with f(i).

If the length is not specified, the Iterable will be infinite.

Note. length is normalized to an integer >= 1.

Example

import * as assert from "node:assert"
import { makeBy } from "effect/Iterable"

assert.deepStrictEqual(Array.from(makeBy(n => n * 2, { length: 5 })), [0, 2, 4, 6, 8])

Signature

declare const makeBy: <A>(f: (i: number) => A, options?: { readonly length?: number; }) => Iterable<A>

Source

Since v2.0.0