between and among: worth Phobosization?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 17 13:57:53 PST 2013


On 12/17/13 1:29 PM, Chris Cain wrote:
> It
> doesn't necessarily have to be called "between" but some sort of object
> (being able to contain the state is important) could contain the concept
> of a range of values ("inclusive lowerbound", "exclusive upperbound",
> support things like "opIn" or an opCall to test a value for membership).

Interval arithmetic (http://en.wikipedia.org/wiki/Interval_arithmetic) 
comes to mind. Like bounds-checked numbers, units, and probabilities, 
it's one of those bread-and-butter types that nobody got around to 
implement for Phobos yet.

In an interval arithmetic approach numbers would compare actually equal, 
i.e. 10 == IntervalInt(5, 100) would be true.


Andrei



More information about the Digitalmars-d mailing list