effect-io-ai

Package: effect
Module: Array

Array.splitAt

Splits an iterable into two arrays at the given index.

When to use

Use to divide an array into a prefix and suffix at a specific position.

Details

n can be 0, in which case all elements are placed in the second array. The index is floored to an integer.

Example (Splitting at an index)

import { Array } from "effect"

console.log(Array.splitAt([1, 2, 3, 4, 5], 3)) // [[1, 2, 3], [4, 5]]

See

Signature

declare const splitAt: { (n: number): <A>(self: Iterable<A>) => [beforeIndex: Array<A>, fromIndex: Array<A>]; <A>(self: Iterable<A>, n: number): [beforeIndex: Array<A>, fromIndex: Array<A>]; }

Source

Since v2.0.0