Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Tony Morris
Yeah that looks useful indeed. I am surprised there isn't a DIET on hackage. On Tue, Oct 30, 2012 at 3:55 AM, Stephen Tetley wrote: > Are Martin Erwig's "diets" anything close? > > http://web.engr.oregonstate.edu/~erwig/diet/ > > On 29 October 2012 04:48, Tony Morris wrote: > > Hi, > > I was won

Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Stephen Tetley
Are Martin Erwig's "diets" anything close? http://web.engr.oregonstate.edu/~erwig/diet/ On 29 October 2012 04:48, Tony Morris wrote: > Hi, > I was wondering if anyone knows of a package implementing a fast lookup > for an element in ranges. > > For example, this operation: > Ord a => a -> [(a, a

Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Chaddaï Fouché
On Mon, Oct 29, 2012 at 9:43 AM, Tony Morris wrote: > It is not a Set, but a Map. Of course, I could use it to implement the > function I need with something like: type SSet a = STree [()] a, but > then I'd have to unnecessarily go beyond Haskell98. > Couldn't you just use : > instance Measured

Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Tony Morris
It is not a Set, but a Map. Of course, I could use it to implement the function I need with something like: type SSet a = STree [()] a, but then I'd have to unnecessarily go beyond Haskell98. Hoping there might be an interval tree or segment tree specifically for this task. On 29/10/12 18:36, Rom

Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Roman Cheplyaka
If you searched hackage, you'd find http://hackage.haskell.org/package/SegmentTree Roman * Tony Morris [2012-10-29 15:38:07+1000] > Er, oops. > > ...can be implemented as: > \a rs -> let s = Set.fromList (rs >>= \(a, b) -> [a..b]) in a `member` s > > Something like that! > > On Mon, Oct 29, 2

Re: [Haskell-cafe] Segment Tree based Set

2012-10-28 Thread Tony Morris
Er, oops. ...can be implemented as: \a rs -> let s = Set.fromList (rs >>= \(a, b) -> [a..b]) in a `member` s Something like that! On Mon, Oct 29, 2012 at 2:48 PM, Tony Morris wrote: > Hi, > I was wondering if anyone knows of a package implementing a fast lookup > for an element in ranges. > >

[Haskell-cafe] Segment Tree based Set

2012-10-28 Thread Tony Morris
Hi, I was wondering if anyone knows of a package implementing a fast lookup for an element in ranges. For example, this operation: Ord a => a -> [(a, a)] -> Bool ...can be implemented: \a rs -> let s = Set.fromList rs in a `member` s This is not particularly efficient. A segment tree seems like