A "high-level" language for the Gameboy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
592 B

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),
])