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 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?  In this example, "rabble"
> > would match :roger.  "b" would match :amit.
>
> > Currently, I'm doing a "some" which has a predicate function which
> > contains another "some" seems awkward to me, but works:
>
> > Assuming the search-str has to be transformed in some way (that I'm
> > leaving out here), using:
> > (defn munge-str [search-str]
> > ... returns a string...)
>
> > (defn key-from-match [search-str]
> >   (let [key-of-str? (fn [entry-pair]
> >                               (if (some #(= (munge-str search-str) %)
> > (val entry-pair))
> >                                 (key entry-pair)))]
> >     (some key-of-str? (players))
> >     ))
>
> > Thanks for any suggestions.
>
> > Kyle

-- 
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

Reply via email to