effect-io-ai

Package: effect
Module: Array

Array.split

Splits an iterable into n roughly equal-sized chunks.

When to use

Use to distribute elements across a fixed number of groups, such as when splitting work across threads.

Details

Uses chunksOf(ceil(length / n)) internally. The last chunk may be shorter.

Example (Splitting into groups)

import { Array } from "effect"

console.log(Array.split([1, 2, 3, 4, 5, 6, 7, 8], 3)) // [[1, 2, 3], [4, 5, 6], [7, 8]]

See

Signature

declare const split: { (n: number): <A>(self: Iterable<A>) => Array<Array<A>>; <A>(self: Iterable<A>, n: number): Array<Array<A>>; }

Source

Since v2.0.0