Skip to main content
Module

x/fun/array.ts>alt

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function alt
import { alt } from "https://deno.land/x/fun@v2.0.0/array.ts";

Given two arrays first and second, if first is default the return second, otherwise return first.

Examples

Example 1

import * as A from "./array.ts";
import { pipe } from "./fn.ts";

const result1 = pipe(
  A.init<number>(),
  A.alt(A.wrap(1)),
); // [1]
const result2 = pipe(
  A.array(1, 2, 3),
  A.alt(A.array(3, 2, 1)),
); // [1, 2, 3]

Parameters

second: ReadonlyArray<A>

Returns

(first: ReadonlyArray<A>) => ReadonlyArray<A>