effect-io-ai

Package: effect
Module: Tuple

Tuple.pick

Creates a new tuple containing only the elements at the specified indices.

When to use

Use to select a subset of elements from a tuple by position.

Details

The result order matches the order of the provided indices.

Example (Selecting elements by index)

import { Tuple } from "effect"

const result = Tuple.pick(["a", "b", "c", "d"], [0, 2, 3])
console.log(result) // ["a", "c", "d"]

See

Signature

declare const pick: { <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => PickTuple<T, I[number]>; <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): PickTuple<T, I[number]>; }

Source

Since v4.0.0