Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ianmackenzie/elm-interval
Simple Interval type for Elm
https://github.com/ianmackenzie/elm-interval
Last synced: 2 months ago
JSON representation
Simple Interval type for Elm
- Host: GitHub
- URL: https://github.com/ianmackenzie/elm-interval
- Owner: ianmackenzie
- License: mpl-2.0
- Created: 2018-02-12T19:06:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-16T20:42:08.000Z (almost 4 years ago)
- Last Synced: 2024-08-01T13:23:33.661Z (4 months ago)
- Language: Elm
- Size: 36.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ccamel - ianmackenzie/elm-interval - Simple Interval type for Elm (Elm)
README
# elm-interval
This package implements a simple `Interval` type for Elm. Both `Int` and `Float`
intervals are supported, for example:```elm
rgbRange : Interval Int
rgbRange =
Interval.from 0 255angleRange : Interval Float
angleRange =
Interval.from 0 (2 * pi)
```Various functionality is included for constructing intervals (including as the
hull or intersection of other intervals), checking for
overlap/intersection/containment, and performing limited arithmetic on
intervals:```elm
unitInterval =
Interval.from 0 1Interval.endpoints unitInterval
--> ( 0, 1 )Interval.hull 5 [ 3, 2, 4 ]
--> Interval.from 2 5Interval.union
(Interval.from 1 2)
(Interval.from 3 5)
--> Interval.from 1 5Interval.intersection
(Interval.from 1 3)
(Interval.from 2 5)
--> Just (Interval.from 2 3)Interval.intersection
(Interval.from 1 2)
(Interval.from 3 5)
--> NothingInterval.contains 0 (Interval.from -1 3)
--> TrueInterval.contains 5 (Interval.from -1 3)
--> FalseInterval.sin (Interval.from 0 pi)
--> Interval.from 0 1
```