Re: bimaps in clojure

2010-11-20 Thread David Nolen
On Tue, Nov 16, 2010 at 4:06 AM, Christophe Grand wrote: > You can implement your own, prettu easily with deftype. > However it can be tedious to track every methods, so we need a repl helper > function to scaffold the code for us. > > (defn scaffold [iface] > (doseq [[iface methods] (->> iface

Re: bimaps in clojure

2010-11-19 Thread Wilson MacGyver
In guava, there is an immutable version of bimap. http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableBiMap.html On Fri, Nov 19, 2010 at 3:24 AM, Christophe Grand wrote: > One call away but rarely persistent or even immutable. > > On Fri, Nov 19, 2010 at 4:

Re: bimaps in clojure

2010-11-19 Thread Christophe Grand
One call away but rarely persistent or even immutable. On Fri, Nov 19, 2010 at 4:55 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > awesome.. :) i keep forgetting that all of java is just a call away .. hmm > thanks Lachlan..:) > Sunil. > > > On Fri, Nov 19, 2010 at 7:46 AM, jlk wr

Re: bimaps in clojure

2010-11-18 Thread Wilson MacGyver
Actually if you want to use java lib. Look at guava, formerly known as google collection. It's one of my fav java lib. http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/BiMap.html On Nov 18, 2010, at 10:55 PM, Sunil S Nandihalli wrote: > awesome.. :) i keep for

Re: bimaps in clojure

2010-11-18 Thread Sunil S Nandihalli
awesome.. :) i keep forgetting that all of java is just a call away .. hmm thanks Lachlan..:) Sunil. On Fri, Nov 19, 2010 at 7:46 AM, jlk wrote: > I haven't tried it, but I just stumbled across > http://commons.apache.org/collections/ > -> BidiMap, might be what you're after? > > > On Nov 16, 6:

Re: bimaps in clojure

2010-11-18 Thread jlk
I haven't tried it, but I just stumbled across http://commons.apache.org/collections/ -> BidiMap, might be what you're after? On Nov 16, 6:14 pm, Sunil S Nandihalli wrote: > Hello everybody, > > Is there something like a bimap in clojure? I know I can have two regular > hash-maps .. but I was w

Re: bimaps in clojure

2010-11-17 Thread Sunil S Nandihalli
Hi Christophe Grand Yea true I kind of got confused .. thanks for the solution.. Sunil On Wed, Nov 17, 2010 at 1:12 PM, Christophe Grand wrote: > On Wednesday, November 17, 2010, Sunil S Nandihalli > wrote: > > Regarding your bimap implementation, in terms of complexity, I feel, it > will be lin

Re: bimaps in clojure

2010-11-16 Thread Christophe Grand
On Wednesday, November 17, 2010, Sunil S Nandihalli wrote: > Regarding your bimap implementation, in terms of complexity, I feel, it will > be linear in the number of elements, when accessing the pair via the value .. > Is that true? No I use two maps and rmap is O(1) so rmap+get is O(log32 n)

Re: bimaps in clojure

2010-11-16 Thread Ken Wesson
On Tue, Nov 16, 2010 at 10:18 PM, Sunil S Nandihalli wrote: > Thanks Christopher Grand. I really like your scaffold .. would be extremely > handy .. Like david suggested .. it would be a perfect candidate for > inclusion in the clojure.repl > Regarding your bimap implementation, in terms of comple

Re: bimaps in clojure

2010-11-16 Thread Mark Engelberg
On Tue, Nov 16, 2010 at 7:18 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Thanks Christopher Grand. I really like your scaffold .. would be extremely > handy .. Like david suggested .. it would be a perfect candidate for > inclusion in the clojure.repl > > Regarding your bimap imp

Re: bimaps in clojure

2010-11-16 Thread Sunil S Nandihalli
Thanks Christopher Grand. I really like your scaffold .. would be extremely handy .. Like david suggested .. it would be a perfect candidate for inclusion in the clojure.repl Regarding your bimap implementation, in terms of complexity, I feel, it will be linear in the number of elements, when acce

Re: bimaps in clojure

2010-11-16 Thread Christophe Grand
You can implement your own, prettu easily with deftype. However it can be tedious to track every methods, so we need a repl helper function to scaffold the code for us. (defn scaffold [iface] (doseq [[iface methods] (->> iface .getMethods (map #(vector (.getName (.get

Re: bimaps in clojure

2010-11-15 Thread Sunil S Nandihalli
A bimap is a map where each elements of the pair can be used as key to access it.. Sunil. On Tue, Nov 16, 2010 at 12:44 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hello everybody, > > Is there something like a bimap in clojure? I know I can have two regular > hash-maps .. but I

bimaps in clojure

2010-11-15 Thread Sunil S Nandihalli
Hello everybody, Is there something like a bimap in clojure? I know I can have two regular hash-maps .. but I was wondering if there is a better implementation..? a similar implementation in c++ is http://beta.boost.org/doc/libs/1_41_0/libs/bimap/doc/html/index.html Thanks, Sunil. -- You rec