I agree there are going to be problems with implementation as-well .. for example if not all the keys in the current map are not in the kmap ... but situation can be handled however, if we passed a function this is going to be harder .. ..
On Wed, May 11, 2011 at 8:26 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hello everybody, > I tried to use clojure.set/rename-keys .. I kind of felt it has a little > odd behaviour... for example .. > > (clojure.set/rename-keys {1 :a 2 :b 3 :c} {1 2 2 3 3 4}) > > returns > > {4 :a} > > I think a more reasonable behavior would be to have it return > > {2 :a 3 :b 4 :c} > > a further enhancement suggestion would be to accept a function instead of a > map that way even the existing code will not break since the map already > implements IFn > > a sample implementation which takes the above into account would be .. > > (defn rename-keys [mp kmap-fn] > (into {} (map (fn [[key val]] [(kmap-fn key) val]) mp))) > > > Thanks, > Sunil. > -- 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