Public
Edited
Oct 27, 2023
1 fork
38 stars
Insert cell
Insert cell
A = [6, 2, 8, 8, 0, 0, 3, 9, 4, 4]
Insert cell
B = [2, 8, 4, 5, 3, 1, 6, 0, 0, 4]
Insert cell
C = [6, 8, 4, 4, 1, 8, 4, 7, 0, 8]
Insert cell
Insert cell
intersection = d3.intersection(A, B)
Insert cell
Insert cell
intersection.has(2) // 2 is in both A and B
Insert cell
intersection.size // 6 distinct values are present in both A and B
Insert cell
Insert cell
d3.intersection(B, A)
Insert cell
Insert cell
d3.intersection() // empty set ∅
Insert cell
d3.intersection(A) // equivalent to new Set(A)
Insert cell
d3.intersection(A, B, C) // A ∩ B ∩ C
Insert cell
Insert cell
d3.union() // empty set ∅
Insert cell
d3.union(A) // equivalent to new Set(A)
Insert cell
d3.union(A, B) // A ∪ B
Insert cell
d3.union(C, B, A) // C ∪ B ∪ A
Insert cell
Insert cell
d3.difference(A, B) // A - B
Insert cell
d3.difference(B, A) // B - A
Insert cell
Insert cell
d3.superset(A, B) // A ⊇ B
Insert cell
d3.subset(A, B) // A ⊆ B
Insert cell
d3.disjoint(A, B) // A ∩ B = ∅?
Insert cell
Insert cell
Insert cell
d3 = require("d3-array@^2.8.0")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more