A Scala library for intervals.
Add the following to your sbt build (2.12.x, 2.13.x, 3.0.x):
val version = "..."
libraryDependencies += Seq(
"com.github.j5ik2o" %% "intervals-scala" % version,
)
- open interval
val range =
Interval.over(Limit(BigDecimal(-5.5)), lowerIncluded = false, Limit(BigDecimal(6.6)), upperIncluded = true)
assert(range.includes(Limit(BigDecimal(5.0))))
assert(!range.includes(Limit(BigDecimal(-5.5))))
assert(range.includes(Limit(BigDecimal(-5.4999))))
assert(range.includes(Limit(BigDecimal(6.6))))
assert(!range.includes(Limit(BigDecimal(6.601))))
assert(!range.includes(Limit(BigDecimal(-5.501))))
- closed interval
val range = Interval.closed(Limit(BigDecimal(-5.5)), Limit(BigDecimal(6.6)))
assert(range.includes(Limit(BigDecimal(5.0))))
assert(range.includes(Limit(BigDecimal(-5.5))))
assert(range.includes(Limit(BigDecimal(-5.4999))))
assert(range.includes(Limit(BigDecimal(6.6))))
assert(!range.includes(Limit(BigDecimal(6.601))))
assert(!range.includes(Limit(BigDecimal(-5.501))))
MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)