Actually, a combination of into & empty does the trick amazingly well...
http://fulldisclojure.blogspot.com/2010/01/12-fn-proposal-same-multisame.html On Feb 21, 10:56 pm, Mike Meyer <mwm-keyword-googlegroups. 620...@mired.org> wrote: > In working through a recent project, I realized that Clojure has a > nice collection of functions for working with maps. However, it > doesn't seem to have analogues of some of the important sequence tools > (filter and map most noticeably, probably others). > > Given that map will take a map as a collection argument - generating a > sequence of entries - it isn't hard to write those analogues. Turning > them back into maps is sort of ugly, because there doesn't seem to be > a natural way to turn a sequence of entries into a map (someone > correct me?), but still not hard. > > There are some issues with doing this in general - do you use keys, > values or entries from the map? If you're modifying instead of > filtering, do you modify the key, value or entry? Rolling your own, > you can decide what you need when you write it, but trying to > generalize them all might get ugly. > > The nasty part of all this is that I seem to have to specify the > resulting map type in the function that turns the sequence of entries > back into keys. I.e. - if I want to run the same filter over both a > hash-map and a sorted-map and need to preserve the sortedness, I > either need two map filter functions, or have to turn the hash-map > into a sorted-map after filtering it. > > Hmm - there doesn't even seem to be an easy way to convert between the > two map types. > > So, the questions: what have I missed in clojure & contrib: Is there a > function that accepts a sequence of [key value] vectors and creates a > map of some sort? Is there a sane way to say "please give me a creator > of the type of this object"? How about a function that accepts a > hash-map as an argument and returns a sorted-map of the entries? > > Thanks, > <mike > -- > Mike Meyer <m...@mired.org> http://www.mired.org/consulting.html > Independent Network/Unix/Perforce consultant, email for more information. > > O< ascii ribbon campaign - stop html mail -www.asciiribbon.org -- 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