Full generation, file type cleanup

This commit is contained in:
Christoph Hagen
2024-12-25 18:06:05 +01:00
parent 41887a1401
commit 1e4682dad1
56 changed files with 1577 additions and 1103 deletions

View File

@ -6,4 +6,8 @@ extension Array {
Array(self[$0..<Swift.min($0 + size, count)])
}
}
var nonEmpty: Self? {
isEmpty ? nil : self
}
}

View File

@ -0,0 +1,11 @@
prefix operator ~>
prefix func ~> (operation: () throws -> Void) -> Bool {
do {
try operation()
return true
} catch {
return false
}
}

View File

@ -27,3 +27,20 @@ extension Collection {
}
}
extension Collection where Element: Collection, Element.Element: Hashable {
func union() -> Set<Element.Element> {
reduce(into: []) { $0.formUnion($1) }
}
}
extension RangeReplaceableCollection where Element: Comparable {
mutating func insertSorted(_ element: Element) {
let index = firstIndex(where: { $0 > element }) ?? endIndex
insert(element, at: index)
}
}