This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Missing concept in Scala standard library: Intervals?

2 replies
Ben Hutchison 3
Joined: 2009-11-02,
User offline. Last seen 42 years 45 weeks ago.

Are Intervals sufficiently common to add to the standard scala library?

For an ordered type T, we can define an Interval[T].

* It has two ends, which might be open (unbounded) or closed (bounded
at a value).
* Closed bounds might be inclusive or exclusive of the bound

Ranges can be used as intervals. We can test whether objects are
within the interval. We can find the union and intersection of
intervals. Similar to
http://en.wikipedia.org/wiki/Interval_(mathematics) but extending
beyond numbers to other ordered objects.

Widely useful? (I think so, given that Im raising the topic)

-Ben

James Moore
Joined: 2010-04-28,
User offline. Last seen 15 weeks 3 days ago.
Re: Missing concept in Scala standard library: Intervals?

On Wed, Oct 19, 2011 at 3:17 PM, Ben Hutchison wrote:
> Are Intervals sufficiently common to add to the standard scala library?

Like the Range just added to Guava
(http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common...)?

Tom Switzer
Joined: 2011-07-19,
User offline. Last seen 42 years 45 weeks ago.
Re: Missing concept in Scala standard library: Intervals?
+1. I think they'd be great and I'd use 'em.

On Wed, Oct 19, 2011 at 6:17 PM, Ben Hutchison <brhutchison [at] gmail [dot] com> wrote:
Are Intervals sufficiently common to add to the standard scala library?

For an ordered type T, we can define an Interval[T].

* It has two ends, which might be open (unbounded) or closed (bounded
at a value).
* Closed bounds might be inclusive or exclusive of the bound

Ranges can be used as intervals. We can test whether objects are
within the interval. We can find the union and intersection of
intervals. Similar to
http://en.wikipedia.org/wiki/Interval_(mathematics) but extending
beyond numbers to other ordered objects.

Widely useful? (I think so, given that Im raising the topic)

-Ben

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland