Skip to main content
Module

x/fun/mod.ts>set.union

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

Given an instance of Comparable return a function that takes two ReadonlySets and merges them into a new ReadonlySet that contains all the elements from both sets.

Examples

Example 1

import * as S from "./set.ts";
import * as N from "./number.ts";
import { pipe } from "./fn.ts";

const union = S.union(N.ComparableNumber);
const s1 = S.set(1, 2, 3, 4);
const s2 = S.set(3, 4, 5, 6);

const result = pipe(s1, union(s2));
// Set(1, 2, 3, 4, 5, 6)

Parameters

S: Comparable<A>

Returns

(second: ReadonlySet<A>) => (first: ReadonlySet<A>) => ReadonlySet<A>