https://github.com/AlexandreDecan/portion
import portion as P
P.closed(0.1, 0.2) | P.closed(0.05, 0.15) | P.closed(0.3,0.4)
[0.05,0.2] | [0.3,0.4]
c1 = P.closed(0.1, 0.2)
c2 = P.closed(0.05, 0.15)
c3 = P.closed(0.3,0.4)
c4 = c1.union(c2).union(c3)
list(c4)
[[0.05,0.2], [0.3,0.4]]
>>> list(P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))
[[0,1], (10,11), [20,21]]
>>> list(P.empty())
[]
>>> (P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))[0]
[0,1]
>>> (P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))[-2]
(10,11)
>>> (P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))[:2]
[0,1] | (10,11)
网友评论