File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 23
23
ClosedInterval (i:: AbstractInterval ) = convert (ClosedInterval{eltype (i)}, i)
24
24
(:: Type{ClosedInterval{T}} ){T}(i:: AbstractInterval ) = convert (ClosedInterval{T}, i)
25
25
26
+ """
27
+ iv = l..r
28
+
29
+ Construct a ClosedInterval `iv` spanning the region from `l` to `r`.
30
+ """
26
31
.. (x, y) = ClosedInterval (x, y)
27
32
33
+ """
34
+ iv = center±halfwidth
35
+
36
+ Construct a ClosedInterval `iv` spanning the region from
37
+ `center - halfwidth` to `center + halfwidth`.
38
+ """
28
39
± (x, y) = ClosedInterval (x - y, x + y)
29
40
± (x:: CartesianIndex , y) = map (ClosedInterval, (x - y). I, (x + y). I)
30
41
@@ -72,6 +83,12 @@ issubset(A::ClosedInterval, B::ClosedInterval) = ((A.left in B) && (A.right in B
72
83
73
84
⊇ (A:: ClosedInterval , B:: ClosedInterval ) = issubset (B, A)
74
85
86
+ """
87
+ w = width(iv)
88
+
89
+ Calculate the width (max-min) of interval `iv`. Note that for integers
90
+ `l` and `r`, `width(l..r) = length(l:r) - 1`.
91
+ """
75
92
function width {T} (A:: ClosedInterval{T} )
76
93
_width = A. right - A. left
77
94
max (zero (_width), _width) # this works when T is a Date
You can’t perform that action at this time.
0 commit comments