Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-13 Thread mudphone
ataggart ( sean): Thanks! I over-looked that in my haste to respond. lambdatronic: That's a very slick use of and in the outer some! I quite like that. Thanks to all again. On Dec 11, 5:20 pm, lambdatronic gwjoh...@uvm.edu wrote: This shaves 7 characters off Sean's solution and short

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-12 Thread lambdatronic
This shaves 7 characters off Sean's solution and short circuits just as fast: (some #(and (some #{rabble} (val %)) (key %)) players) Happy hacking! On Dec 10, 3:29 pm, Sean Devlin francoisdev...@gmail.com wrote: Oops!  Slight mistake (ffirst (filter (comp (partial some #{rabble}) val)

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-11 Thread mudphone
Thanks for the suggestions. I think since the original version short circuits when it finds a result (using some), that's probably what I have to stick with. One thing I didn't mention in the original problem statement is that my players map can be large. Again, thanks for the ideas. Kyle --

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-11 Thread ataggart
On Dec 11, 10:44 am, mudphone kyle...@gmail.com wrote: Thanks for the suggestions. I think since the original version short circuits when it finds a result (using some), that's probably what I have to stick with. Sean's solution does as well. -- You received this message because you are

Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-10 Thread mudphone
Hi Folks, So, I have a search string, for example rabble. And a map which contains keyword keys, and vectors of strings as values: (def players { :amit [a b c] :roger [rabble x y] }) Is there an idiomatic way to search for rabble in the vector values, then return the keyword that matches it?

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-10 Thread Sean Devlin
Try this... (second (first (filter (comp (partial some #{rabble}) val) players))) On Dec 10, 2:40 pm, mudphone kyle...@gmail.com wrote: Hi Folks, So, I have a search string, for example rabble.  And a map which contains keyword keys, and vectors of strings as values: (def players { :amit

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-10 Thread Sean Devlin
Oops! Slight mistake (ffirst (filter (comp (partial some #{rabble}) val) players)) On Dec 10, 3:27 pm, Sean Devlin francoisdev...@gmail.com wrote: Try this... (second (first (filter (comp (partial some #{rabble}) val) players))) On Dec 10, 2:40 pm, mudphone kyle...@gmail.com wrote: Hi

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-10 Thread Meikel Brandmeyer
Hi, Am 10.12.2009 um 20:40 schrieb mudphone: So, I have a search string, for example rabble. And a map which contains keyword keys, and vectors of strings as values: (def players { :amit [a b c] :roger [rabble x y] }) (defn key-from-match [search-str] (let [key-of-str? (fn