|
|
- export const intersect = <A>(xs: Set<A>, ys: Set<A>): Set<A> => {
- const out: Set<A> = new Set()
-
- xs.forEach(x => {
- if (ys.has(x)) {
- out.add(x)
- }
- })
-
- return out
- }
-
- export const setEquals = <A>(xs: Set<A>, ys: Set<A>): boolean => {
- if (xs.size != ys.size) {
- return false
- }
-
- for (const x of Array.from(xs)) {
- if (!ys.has(x)) {
- return false
- }
- }
-
- return true
- }
-
- export const union = <A>(xs: Set<A>, ys: Set<A>): Set<A> =>
- new Set([
- ...Array.from(xs),
- ...Array.from(ys),
- ])
|