3 ms·
I wish there was an interval set in Python's builtins. I also wish that ranges were an actual proper set implementation - so you could, for example, take inter
by TheLoneWolfling 12y ago
I wish there was an interval set in Python's builtins.
I also wish that ranges were an actual proper set implementation - so you could, for example, take intersection and union of ranges.
And I wish that Python had an explicit concatenation operator.
- Spiritus 12y agoYou mean like the built in `set` object? https://docs.python.org/2/library/stdtypes.html#set https://docs.python.org/2/library/stdtypes.html#set
- omaranto 12y agoI think he or she meant a specialized set data structure that stores sets of numbers which can be written as finite unions of interval. Typically besides set operations you'd also want (1) that only endpoints of the intervals are stored, so that the structure is compactly represented in memory, (2) to be able to recover the canonical representation of the set as a sorted union of disjoint intervals.
- TheLoneWolfling 12y agoThis is exactly what I meant, thank you.
- TheLoneWolfling 12y agoSet doesn't work for this. You need to store all possible numbers between the lower and upper bound, which isn't exactly workable for (for example) floats.