Albatross: interval sets in Scala

165 views
Skip to first unread message

Dominic Fox

unread,
Apr 5, 2013, 10:43:01 AM4/5/13
to scala...@googlegroups.com
I've written a small Scala library for doing things with interval sets - that is, sets that are defined in terms of the ranges of values they enclose, e.g.

closed(0) to closed(5)                  // [1...5]
closed(today) to open(nextFriday) // today to next Friday, not inclusive
unbounded[Double] to open(0.0)   // all non-zero negative Doubles

The functionality is similar to that of Guava's Ranges, except that non-continuous intervals are also supported, e.g.

(closed(0) to closed(5)) union (closed(10) to closed(15)) // [1...5] U [10...15]
(closed(0) to closed(15)) complement (open(5) to open(10)) // [1...5] U [10...15]

The code, plus further examples, is on github here: https://github.com/youdevise/albatross

Dominic

Tom Switzer

unread,
Apr 9, 2013, 10:47:43 AM4/9/13
to Dominic Fox, scala-user
Awesome! I saw you deal with discrete types specially -- any chance of having a separate discrete interval set that actually extends Set/Iterable? Also, any chance of supporting a more general Map? You'd need to return Lists of values from the map though, rather than an Option.



Dominic

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages