Skip to content

Commit 5da8cf9

Browse files
authored
Merge pull request #4 from JuliaMath/teh/readme
Add content to the README
2 parents 828b291 + 99a25c8 commit 5da8cf9

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,62 @@ Interval Sets for Julia
44
[![Build Status](https://travis-ci.org/JuliaMath/IntervalSets.jl.svg?branch=master)](https://travis-ci.org/JuliaMath/IntervalSets.jl)
55

66
[![Coverage Status](https://coveralls.io/repos/github/JuliaMath/IntervalSets.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaMath/IntervalSets.jl?branch=master)
7+
8+
This package represents intervals of an ordered set. For an interval
9+
spanning from `a` to `b`, all values `x` that lie between `a` and `b`
10+
are defined as being members of the interval.
11+
12+
Currently this package defines one concrete type, `ClosedInterval`.
13+
These define the closed set spanning from `a` to `b`, meaning the
14+
interval is defined as the set `{x}` satisfying `a ≤ x ≤ b`. This is
15+
sometimes written `[a,b]` (mathematics syntax, not Julia syntax) or
16+
`a..b`.
17+
18+
## Usage
19+
20+
You can construct `ClosedInterval`s in a variety of ways:
21+
22+
```julia
23+
julia> using IntervalSets
24+
25+
julia> ClosedInterval{Float64}(1,3)
26+
1.0..3.0
27+
28+
julia> 0.5..2.5
29+
0.5..2.5
30+
31+
julia> 1.5±1
32+
0.5..2.5
33+
```
34+
35+
The `±` operator may be typed as `\pm<TAB>` (using Julia's LaTeX
36+
syntax tab-completion).
37+
38+
Intervals also support the expected set operations:
39+
40+
```julia
41+
julia> 1.75 1.5±1 # \in<TAB>; can also use `in`
42+
true
43+
44+
julia> 0 1.5±1
45+
false
46+
47+
julia> intersect(1..5, 3..7) # can also use `a ∩ b`, where the symbol is \cap<TAB>
48+
3..5
49+
50+
julia> isempty(intersect(1..5, 10..11))
51+
true
52+
53+
julia> (0.25..5) (3..7.4) # \cup<TAB>; can also use union()
54+
0.25..7.4
55+
```
56+
57+
When computing the union, the result must also be an interval:
58+
```julia
59+
julia> (0.25..5) (6..7.4)
60+
------ ArgumentError ------------------- Stacktrace (most recent call last)
61+
62+
[1] — union(::IntervalSets.ClosedInterval{Float64}, ::IntervalSets.ClosedInterval{Float64}) at closed.jl:34
63+
64+
ArgumentError: Cannot construct union of disjoint sets.
65+
```

0 commit comments

Comments
 (0)