import type { Either } from "../../../Either/core.js"; import type { Predicate, Refinement } from "../../../Function/core.js"; import type { Option } from "../../../Option/index.js"; import type { Dictionary } from "../Dictionary/index.js"; import type { NonEmptyArray } from "../NonEmptyArray/index.js"; import * as Tp from "../Tuple/index.js"; import * as C from "./core.js"; /** * Classic Applicative's ap */ export declare function ap(fa: C.Array): (fab: C.Array<(a: A) => B>) => C.Array; /** * Classic Applicative's ap */ export declare function ap_(fab: C.Array<(a: A) => B>, fa: C.Array): C.Array; /** * Array comprehension * * ``` * [ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ] * ``` * * ```ts * assert.deepStrictEqual(comprehension([[1, 2, 3], ['a', 'b']], tuple, (a, b) => (a + b.length) % 2 === 0), [ * [1, 'a'], * [1, 'b'], * [3, 'a'], * [3, 'b'] * ]) * ``` */ export declare function comprehension(input: readonly [Array, C.Array, C.Array, C.Array], f: (a: A, b: B, c: C, d: D) => R, g?: (a: A, b: B, c: C, d: D) => boolean): C.Array; export declare function comprehension(input: readonly [C.Array, C.Array, C.Array], f: (a: A, b: B, c: C) => R, g?: (a: A, b: B, c: C) => boolean): C.Array; export declare function comprehension(input: readonly [C.Array], f: (a: A) => R, g?: (a: A) => boolean): C.Array; export declare function comprehension(input: readonly [C.Array, C.Array], f: (a: A, b: B) => R, g?: (a: A, b: B) => boolean): C.Array; export declare function comprehension(input: readonly [C.Array], f: (a: A) => boolean, g?: (a: A) => R): C.Array; /** * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds * * ```ts * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3])) * assert.deepStrictEqual(deleteAt(1)([]), none) * ``` */ export declare function deleteAt(i: number): (as: C.Array) => Option>; /** * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds */ export declare function deleteAt_(as: C.Array, i: number): Option>; /** * Array[A] => Array[Array[A]] */ export declare function duplicate(ma: C.Array): C.Array>; /** * Extends calls f with all the progressive slices up to the current element's index, * and uses the return value to construct the result array * * i.e: like map that also consumes all the elements up to `i` */ export declare function extend(f: (fa: C.Array) => B): (ma: C.Array) => C.Array; /** * Extends calls f with all the progressive slices up to the current element's index, * and uses the return value to construct the result array * * i.e: like map that also consumes all the elements up to `i` */ export declare function extend_(ma: C.Array, f: (fa: C.Array) => B): C.Array; /** * Find the first element returned by an option based selector function * * ```ts * interface Person { * name: string * age?: number * } * * const persons: Array = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }] * * // returns the name of the first person that has an age * assert.deepStrictEqual(findFirstMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Mary')) * ``` */ export declare function findFirstMap(f: (a: A) => Option): (as: C.Array) => Option; /** * Find the first element returned by an option based selector function */ export declare function findFirstMap_(as: C.Array, f: (a: A) => Option): Option; /** * Find the first element returned by an option based selector function */ export declare function findFirstMapWithIndex_(as: C.Array, f: (i: number, a: A) => Option): Option; /** * Find the first element returned by an option based selector function * * @ets_data_first findFirstMapWithIndex_ */ export declare function findFirstMapWithIndex(f: (i: number, a: A) => Option): (as: C.Array) => Option; /** * Find the last element returned by an option based selector function * * ```ts * interface Person { * name: string * age?: number * } * * const persons: Array = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }] * * // returns the name of the last person that has an age * assert.deepStrictEqual(findLastMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Joey')) * ``` */ export declare function findLastMap(f: (a: A) => Option): (as: C.Array) => Option; /** * Find the last element returned by an option based selector function */ export declare function findLastMap_(as: C.Array, f: (a: A) => Option): Option; /** * Break an array into its first element and remaining elements * * ```ts * const len: (as: Array) => number = foldLeft(() => 0, (_, tail) => 1 + len(tail)) * assert.strictEqual(len([1, 2, 3]), 3) * ``` */ export declare function foldLeft(onNil: () => B, onCons: (head: A, tail: C.Array) => B): (as: C.Array) => B; /** * Break an array into its first element and remaining elements */ export declare function foldLeft_(as: C.Array, onNil: () => B, onCons: (head: A, tail: C.Array) => B): B; /** * Break an array into its initial elements and the last element */ export declare function foldRight(onNil: () => B, onCons: (init: Array, last: A) => B): (as: Array) => B; /** * Break an array into its initial elements and the last element */ export declare function foldRight_(as: Array, onNil: () => B, onCons: (init: Array, last: A) => B): B; /** * Get all but the last element of an array, creating a new array, or `None` if the array is empty * * ``` * assert.deepStrictEqual(init([1, 2, 3]), some([1, 2])) * assert.deepStrictEqual(init([]), none) * ``` */ export declare function init(as: C.Array): Option>; /** * Insert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds * * ``` * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4])) * ``` */ export declare function insertAt(i: number, a: A): (as: C.Array) => Option>; /** * Insert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds */ export declare function insertAt_(as: C.Array, i: number, a: A): Option>; /** * Inserts index i (non safe) */ export declare function unsafeInsertAt_(as: C.Array, i: number, a: A): C.Array; /** * Inserts index i (non safe) */ export declare function unsafeInsertAt(i: number, a: A): (as: C.Array) => C.Array; /** * Change the element at the specified index, creating a new array, or returning `None` if the index is out of bounds * * ```ts * assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3])) * assert.deepStrictEqual(updateAt(1, 1)([]), none) * ``` */ export declare function updateAt(i: number, a: A): (as: C.Array) => Option>; /** * Change the element at the specified index, creating a new array, or returning `None` if the index is out of bounds */ export declare function updateAt_(as: C.Array, i: number, a: A): Option>; /** * Updates index i (non safe) */ export declare function unsafeUpdateAt_(as: C.Array, i: number, a: A): C.Array; /** * Updates index i (non safe) */ export declare function unsafeUpdateAt(i: number, a: A): (as: C.Array) => C.Array; /** * Extracts from an array of `Either` all the `Left` elements. All the `Left` elements are extracted in order * * ```ts * assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo']) * ``` */ export declare function lefts(as: C.Array>): C.Array; /** * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out * of bounds * * ```ts * const double = (x: number): number => x * 2 * assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3])) * assert.deepStrictEqual(modifyAt(1, double)([]), none) * ``` */ export declare function modifyAt(i: number, f: (a: A) => A): (as: C.Array) => Option>; /** * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out * of bounds */ export declare function modifyAt_(as: C.Array, i: number, f: (a: A) => A): Option>; /** * Extracts from an array of `Either` all the `Right` elements. All the `Right` elements are extracted in order * * ```ts * assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2]) * ``` */ export declare function rights(as: C.Array>): C.Array; /** * Rotate an array to the right by `n` steps * * ```ts * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3]) * ``` */ export declare function rotate(n: number): (as: C.Array) => C.Array; /** * Rotate an array to the right by `n` steps */ export declare function rotate_(as: C.Array, n: number): C.Array; /** * Same as `reduce` but it carries over the intermediate steps * * ```ts * import { scanLeft } from '@matechs/core/Array' * * assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4]) * ``` */ export declare function scanLeft(b: B, f: (b: B, a: A) => B): (as: C.Array) => C.Array; /** * Same as `reduce` but it carries over the intermediate steps */ export declare function scanLeft_(as: C.Array, b: B, f: (b: B, a: A) => B): C.Array; /** * Fold an array from the right, keeping all intermediate results instead of only the final result * * ```ts * assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10]) * ``` */ export declare function scanRight(b: B, f: (a: A, b: B) => B): (as: C.Array) => C.Array; /** * Fold an array from the right, keeping all intermediate results instead of only the final result */ export declare function scanRight_(as: C.Array, b: B, f: (a: A, b: B) => B): C.Array; /** * Takes elements until the predicate returns positively */ export declare function takeUntil(predicate: Refinement): (as: C.Array) => C.Array; export declare function takeUntil(predicate: Predicate): (as: C.Array) => C.Array; /** * Takes elements until the predicate returns positively */ export declare function takeUntil_(as: C.Array, predicate: Refinement): C.Array; export declare function takeUntil_(as: C.Array, predicate: Predicate): C.Array; /** * Deletes index i (non safe) */ export declare function unsafeDeleteAt_(as: C.Array, i: number): C.Array; /** * Deletes index i (non safe) */ export declare function unsafeDeleteAt(i: number): (as: C.Array) => C.Array; /** * Separate Array */ export declare function separate(fa: C.Array>): Tp.Tuple<[C.Array, C.Array]>; /** * Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning * function on each element, and grouping the results according to values returned */ export declare function groupBy(f: (a: A) => string): (as: C.Array) => Dictionary>; /** * Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning * function on each element, and grouping the results according to values returned */ export declare function groupBy_(as: C.Array, f: (a: A) => string): Dictionary>; //# sourceMappingURL=classic.d.ts.map