You can use a map as a key in another map. The clojure.set namespace has a function index that does this:
user=> (doc index) ------------------------- clojure.set/index ([xrel ks]) Returns a map of the distinct values of ks in the xrel mapped to a set of the maps in xrel with the corresponding values of ks. The map you get out of it uses maps as keys. Here's is an example applied to your sample data: (def *data* [ {:cat 1 :gender :male :item-ids [1 2 3 4 5 6 7 8 9]} {:cat 1 :gender :female :item-ids [2 4 5 6607 43 54 234]} {:cat 2 :gender :male :item-ids [1 2 3 4 5 6 7 8 44 6 23 44]} {:cat 2 :gender :female :item-ids [2 4 6 8 10 12 17 38 55]} {:cat 3 :gender :male :item-ids [1 2 3 4]} {:cat 3 :gender :female :item-ids [2 4 6 8 33 45 10 12]} ]) The repl output is a bit long and unwieldy so here is the first element: (first (index *data* [:cat :gender])) [{:gender :female, :cat 3} #{{:cat 3, :gender :female, :item-ids [2 4 6 8 33 45 10 12]}}] And this is how you would lookup a specific element: (let [my-index (index *data* [:cat :gender])] (get my-index {:cat 1 :gender :male})) #{{:cat 1, :gender :male, :item-ids [1 2 3 4 5 6 7 8 9]}} You don't have to use the index function. Your data may not represent a set. I was just using the index function for illustration. On Feb 23, 6:09 pm, Base <basselh...@gmail.com> wrote: > Hi All - > > So this may be an extraordinary dumb question (even for me...) but is > there such a thing as a map with compound keys? > > For example lets say that I have a data set that looks like.... > > Cat Gender item-Id's > 1 M 1 2 3 4 5 6 7 8 9 > 1 F 2 4 5 6607 43 54 234 > 2 M 1 2 3 4 5 6 7 8 44 6 23 44 > 2 F 2 4 6 8 10 12 17 38 55 > 3 M 1 2 3 4 > 3 F 2 4 6 8 33 45 10 12 > ... > > where I would want to do a look up on both the category and the > gender. > > I could do map - in - map, or do something like a (str cat gender) to > amalgamate 2 fields to set the key but I was just wondering if this > even existed. > > How do you all model this data? > > I was using Incanter's data set $where statements for this but have > been having performance issues with it and am trying to speed up this > operation. I have a data set with around 130,000 rows so a map would > really help pare things down in a hurry... > > Sorry for the *really bad* question! > > Thanks > > Base -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en