On Sat, Feb 21, 2009 at 5:31 PM, David Nolen <dnolen.li...@gmail.com> wrote: > Oops, sorry. It seems weird to me that a function called select-keys would > take a single parameter and not a vector. Also, as you said, this does seem > like it would require some kind of check which would probably not worth the > tradeoff. Why not write a function called select-key that does what you > want?
I must not be writing very clearly today. This is what I want to be able to do. (def popsicle-map {:red :cherry, :green :apple, :purple :grape}) (select-keys popsicle-map :red :green :blue) That doesn't work though. It throws java.lang.IllegalArgumentException: Wrong number of args passed to: core$select-keys. I have to wrap the keys in a collection like this instead. (select-keys popsicle-map [:red :green :blue]) However, I can pass any number of individual keys to assoc and dissoc. That's the inconsistency I'm trying to point out. > On Sat, Feb 21, 2009 at 6:24 PM, Mark Volkmann <r.mark.volkm...@gmail.com> > wrote: >> >> On Sat, Feb 21, 2009 at 5:07 PM, David Nolen <dnolen.li...@gmail.com> >> wrote: >> > dissoc is like assoc. >> > If you want to use collections with dissoc you can always use apply. >> > It's >> > not too much to type: >> > (def my-map {:first "Bob", :middle "Joe", :last "Smith"}) >> > (apply dissoc my-map [:first :middle]) >> >> I think you misunderstood what I want. I want to be able to pass >> individual keys to select-keys. I'm not looking for a way to pass >> collections of keys to dissoc and assoc. >> >> My guess is that this inconsistency was purely accidental and could be >> fixed so select-keys also accepts individual key arguments. >> >> > On Sat, Feb 21, 2009 at 5:58 PM, samppi <rbysam...@gmail.com> wrote: >> >> >> >> Allowing dissoc and select-keys to accept both keys as arguments and >> >> as a collection would be nice, and backwards compatible. In any case, >> >> ostensibly it should be consistent; otherwise, it's just an >> >> idiosyncrasy in the language that people will have to deal with. I >> >> wonder what the reasoning is behind it, or if it was completely >> >> arbitrary. >> >> >> >> On Feb 21, 1:28 pm, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: >> >> > (def popsicle-map {:red :cherry, :green :apple, :purple :grape}) >> >> > >> >> > ; Note how the keys passed to dissoc are individual arguments. >> >> > (dissoc popsicle-map :green :blue) ; -> {:red :cherry, :purple >> >> > :grape} >> >> > >> >> > ; Note how the keys passed to select-keys are in a vector, not >> >> > individual arguments. >> >> > (select-keys popsicle-map [:red :green :blue]) ; -> {:green :apple, >> >> > :red :cherry} >> >> > >> >> > I wonder why these were implemented differently. Maybe both dissoc >> >> > and >> >> > select-keys should accept both individual key arguments and a >> >> > sequence >> >> > of keys. -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---