effect-io-ai

Package: effect
Module: Array

Array.extend

Applies a function to each suffix of the array (starting from each index), collecting the results.

When to use

Use when you need to compute a result from every suffix of an array, such as cumulative aggregations from each position.

Details

For index i, the function receives self.slice(i).

Example (Computing suffix lengths)

import { Array } from "effect"

console.log(Array.extend([1, 2, 3], (as) => as.length)) // [3, 2, 1]

See

Signature

declare const extend: { <A, B>(f: (as: ReadonlyArray<A>) => B): (self: ReadonlyArray<A>) => Array<B>; <A, B>(self: ReadonlyArray<A>, f: (as: ReadonlyArray<A>) => B): Array<B>; }

Source

Since v2.0.0