# Julia standard library for interval type

**URL:** <https://discourse.julialang.org/t/julia-standard-library-for-interval-type/60936>\
**Category:** Internals & Design\
**Created:** [May 11, 2021, 7:49am UTC](https://discourse.julialang.org/t/julia-standard-library-for-interval-type/60936 "2021-05-11T07:49:47Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [May 13, 2021, 2:15pm UTC](https://discourse.julialang.org/t/julia-standard-library-for-interval-type/60936/21 "2021-05-13T14:15:55Z")

</div>

Ah I see, this would indeed require a slightly new function which does not forget the endpoint intervals.

---

<div class="post-metadata">

**Author:** ![fph](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fph/32/17159_2.png) [@fph](https://discourse.julialang.org/u/fph)\
**Post date:** [May 13, 2021, 4:26pm UTC](https://discourse.julialang.org/t/julia-standard-library-for-interval-type/60936/22 "2021-05-13T16:26:41Z")

</div>

Exactly! 🙂 `IntervalOptimisation.minimise` does already much more than solving this problem would require, but there is an interface-level issue that makes it unsolvable, and the issue arises precisely from using `a..b` instead of `(a, b)` to specify a domain.

I’m not saying this to point out a flaw (`IntervalOptimisation` does what it promises, and I find it a great piece of work), but I am using it as an example in this discussion about different ways to use intervals and building a unified interface.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 25, 2021, 8:26am UTC](https://discourse.julialang.org/t/julia-standard-library-for-interval-type/60936/23 "2021-05-25T08:26:14Z")

</div>

> [@TheLateKronos](#):
>
> is the concept of an interval not generally useful enough

Yes, intervals are generally useful concepts, but that does not mean that a single one generalizes well in Julia. They come in many forms, and what one would encode in the type (for type stable dispatch) matters on the application.

Eg for a plotting library, a pair of finite numbers suffices. But for a constrained optimization package, which end is open/closed can matter. For a package that maps intervals to some other interval, whether the interval is finite is important.

For these reasons, there are lot of implementations, and I am not sure a single one will emerge as the best solution.

Also, I would only wrap things in a `struct` if I want to treat it as a single unit (eg for the purposes of arithmetic or transformations). Specifically for plotting, this is not a common use case, and frequently you even want to specify just the lower- or upper limit and leave the other one to be determined by the data.

[Previous page](https://discourse.julialang.org/t/julia-standard-library-for-interval-type/60936.md?page=1)
