Programming, Computer Science, JavaScript, Functional Programming.
merge two sets together. Here is our implementation: export opaque type NumberSet = Array<number>; export function empty() : NumberSet { return []; } export function add(n: number, set: NumberSet) : NumberSet { let i = 0; while(n < set[i] && i < set.length) { i++; } if (set[i] === n) return set;