Hyperlinkv0.8.0-beta.28

Array

Array.intersectionconsteffect/Array.ts:3233
<B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<A & B>
<A, B>(self: Iterable<A>, that: Iterable<B>): Array<A & B>

Computes the intersection of two arrays using Equal.equivalence(). Order is determined by the first array.

When to use

Use when Effect equality is the right membership test and you want to keep values present in both inputs while preserving the first input's order.

Example (Computing array intersections)

import { Array } from "effect"

console.log(Array.intersection([1, 2, 3], [3, 4, 1])) // [1, 3]
Source effect/Array.ts:32334 lines
export const intersection: {
  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<A & B>
  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A & B>
} = intersectionWith(Equal.asEquivalence())
Referenced by 2 symbols