Hyperlinkv0.8.0-beta.28

Chunk

Chunk.makeByconsteffect/Chunk.ts:2500
<A>(f: (i: number) => A): (n: number) => NonEmptyChunk<A>
<A>(n: number, f: (i: number) => A): NonEmptyChunk<A>

Returns a non-empty Chunk of length n with element i initialized by f(i).

Details

n is normalized to an integer greater than or equal to 1.

Example (Generating chunks from indices)

import { Chunk } from "effect"

const chunk = Chunk.makeBy(5, (i) => i * 2)
console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8]
constructors
Source effect/Chunk.ts:25004 lines
export const makeBy: {
  <A>(f: (i: number) => A): (n: number) => NonEmptyChunk<A>
  <A>(n: number, f: (i: number) => A): NonEmptyChunk<A>
} = dual(2, (n, f) => fromIterable(RA.makeBy(n, f)))
Referenced by 1 symbols