effect-io-ai

Package: effect
Module: Array

Array.unappend

Splits a non-empty array into all elements except the last, and the last element.

When to use

Use when you need to split a non-empty array into the elements before the last element and the last element.

Details

Returns a tuple [init, last] and requires a NonEmptyReadonlyArray.

Example (Destructuring init and last)

import { Array } from "effect"

const result = Array.unappend([1, 2, 3, 4])
console.log(result) // [[1, 2, 3], 4]

See

Signature

declare const unappend: <A>(self: NonEmptyReadonlyArray<A>) => [arrayWithoutLastElement: Array<A>, lastElement: A]

Source

Since v2.0.0