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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more