Skip to main content
Module

x/fun/set.ts>intersection

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

Given an instance of Comparable return a function that takes two ReadonlySets and returns a new set with only the elements that exist in both sets.

Examples

Example 1

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

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

const result = pipe(s1, intersect(s2));
// Set(3, 4)

Returns

(ua: ReadonlySet<A>) => (tb: ReadonlySet<A>) => ReadonlySet<A>