Skip to content

Commit 77d4bf0

Browse files
authored
Merge pull request #20 from JuliaMath/teh/docstrings
Add a few docstrings
2 parents 1af92d6 + 03a7325 commit 77d4bf0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/closed.jl

+17
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,19 @@ end
2323
ClosedInterval(i::AbstractInterval) = convert(ClosedInterval{eltype(i)}, i)
2424
(::Type{ClosedInterval{T}}){T}(i::AbstractInterval) = convert(ClosedInterval{T}, i)
2525

26+
"""
27+
iv = l..r
28+
29+
Construct a ClosedInterval `iv` spanning the region from `l` to `r`.
30+
"""
2631
..(x, y) = ClosedInterval(x, y)
2732

33+
"""
34+
iv = center±halfwidth
35+
36+
Construct a ClosedInterval `iv` spanning the region from
37+
`center - halfwidth` to `center + halfwidth`.
38+
"""
2839
±(x, y) = ClosedInterval(x - y, x + y)
2940
±(x::CartesianIndex, y) = map(ClosedInterval, (x - y).I, (x + y).I)
3041

@@ -72,6 +83,12 @@ issubset(A::ClosedInterval, B::ClosedInterval) = ((A.left in B) && (A.right in B
7283

7384
(A::ClosedInterval, B::ClosedInterval) = issubset(B, A)
7485

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+
"""
7592
function width{T}(A::ClosedInterval{T})
7693
_width = A.right - A.left
7794
max(zero(_width), _width) # this works when T is a Date

0 commit comments

Comments
 (0)