Jon Lang wrote:
Darren Duncan wrote:
What I'm proposing here in the general case, is a generic collection type,
"Interval" say, that can represent a discontinuous interval of an ordered
type. A simple way of defining such a type is that it is a "Set of Pair of
Ordered", where each Pair defines a continuous interval in terms of 2
ordered end-points, and the whole set is discontinuous (or replace Pair with
Note that you lose the distinction between inclusive and exclusive
endpoints if you do this.
Well, if taken exactly literally that is the case. Or if you interpret it as
"replace pair with 4-element Seq" then you have the incl/excl info too.
That is one benefit that Range has over
Pair: Range _does_ keep track of whether its endpoints are inclusive
or exclusive. The main problem with Range is that it is (usually?)
enumerable - which is generally considered to be a feature, but which
gets in the way in the case of using it to represent a continuous
interval. Thus my suggestion of somehow doing away with the
enumerability if the step size is zero. As such, I'd be inclined to
define Interval as a Range-like role that isn't enumerable,
representing a continuous span between its lower and upper boundaries.
A "disjoint interval" would be a role that usually delegates to an
internal Set of Interval of Type, except when it needs to do otherwise
in order to resemble a Set of Type.
Yes, that would be fine, as you say.
-- Darren Duncan