spire
spire copied to clipboard
Provide extractors for intervals
trafficstars
It would be good to have an easy way to access the maximum and minimum value in the very common case of bounded intervals.
@AlecZorab requested this on gitter. Maybe add extractor objects to spire.math.Interval.
@non Should there be extractor objects for all possible cases, or just for extracting the minimum and maximum in case of a fully bounded interval?
did anything happen to this @rklaehn ?
I am trying to use the Interval and Bound class, for now I am only working on Int. Just to makes things work, now I am doing this crazy thing:
def boundValue(bound: Bound[A])(implicit ev: A =:= Int): Int = bound match {
case Open(a) => a
case Closed(a) => a
case EmptyBound() => 0
case Unbound() => Int.MaxValue
}
Is there a better way? I don't have much experience with this kind of api, but found the Interval class quite useful :-)