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
|
|
}
|