effect-io-ai

Package: effect
Module: HashSet

HashSet.intersection

Returns a HashSet of values which are present in both this set and that Iterable<A>. Computes set intersection (A ∩ B)

Time complexity: O(n) where n is the number of elements in the smaller set

NOTE: the hash and equal of the values in both the set and the iterable must be the same.

Example

// Syntax
import { HashSet, pipe } from "effect"

// with data-last, a.k.a. pipeable API
pipe(HashSet.make(1, 2, 3), HashSet.intersection(HashSet.make(2, 3, 4)))

// or piped with the pipe function
HashSet.make(1, 2, 3).pipe(HashSet.intersection(HashSet.make(2, 3, 4)))

// or with data-first API
HashSet.intersection(HashSet.make(1, 2, 3), HashSet.make(2, 3, 4))

See

Signature

declare const intersection: { <A>(that: Iterable<A>): (self: HashSet<A>) => HashSet<A>; <A>(self: HashSet<A>, that: Iterable<A>): HashSet<A>; }

Source

Since v2.0.0