/** * @tsplus static SortedSet.Aspects flatMap * @tsplus pipeable SortedSet flatMap */ export function flatMap(ord: Ord, f: (a: A) => Collection) { return (self: SortedSet): SortedSet => { let out = SortedSet.empty(ord) self.forEach((a) => { for (const b of f(a)) { if (!out.has(b)) { out = out.add(b) } } }) return out } }