effect-io-ai

Package: effect
Module: Array

Array.modifyHeadNonEmpty

Applies a function to the first element of a non-empty array, returning a new array.

When to use

Use to transform the first element of a non-empty array while preserving the rest.

Example (Modifying the head)

import { Array } from "effect"

console.log(Array.modifyHeadNonEmpty([1, 2, 3], (n) => n * 10)) // [10, 2, 3]

See

Signature

declare const modifyHeadNonEmpty: { <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>; <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>; }

Source

Since v4.0.0