Skip to main content
Module

x/fun/mod.ts>set.intersection

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function set.intersection
import { set } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { intersection } = set;

Given an instance of Eq 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.EqNumber);
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>