Re: [Haskell-cafe] Re: Data.Map: Enumerating ordered subset of keys

2009-02-09 Thread Jared Updike
On 2/8/09, Anish Muttreja wrote: > Maybe you wantData.Map.partition (\key -> key >= key1 && key <= key2) map This will return what I want, but partition is O(n) and touches all the keys, so if I had a million keys and only 2 of them matched the key1..key2 range, it would still visit all of them b

Re: [Haskell-cafe] Re: Data.Map: Enumerating ordered subset of keys

2009-02-09 Thread Jared Updike
I had a similar thought. That will probably do the trick. Jared. On 2/8/09, Svein Ove Aas wrote: > On Mon, Feb 9, 2009 at 8:02 AM, Jared Updike wrote: > > It looks like two "Map.split"s will do what I need except for allowing > > more exact testing of <= vs. < (since == elements are left ou

Re: [Haskell-cafe] Re: Data.Map: Enumerating ordered subset of keys

2009-02-08 Thread Svein Ove Aas
On Mon, Feb 9, 2009 at 8:02 AM, Jared Updike wrote: > It looks like two "Map.split"s will do what I need except for allowing > more exact testing of <= vs. < (since == elements are left out of both > maps...?) > If your key is an instance of Enum, you can use succ/pred to work around that little p

Re: [Haskell-cafe] Re: Data.Map: Enumerating ordered subset of keys

2009-02-08 Thread Anish Muttreja
Maybe you want Data.Map.partition (\key -> key >= key1 && key <= key2) map HTH, Anish On Sun, 08 Feb 2009 23:02:37 -0800, Jared Updike wrote: It looks like two "Map.split"s will do what I need except for allowing more exact testing of <= vs. < (since == elements are left out of both maps...?

[Haskell-cafe] Re: Data.Map: Enumerating ordered subset of keys

2009-02-08 Thread Jared Updike
It looks like two "Map.split"s will do what I need except for allowing more exact testing of <= vs. < (since == elements are left out of both maps...?) Jared. On 2/8/09, Jared Updike wrote: > I would like to enumerate a subset of keys in a Map satisfying \ key > >= key1 && key <= key2 but in