Easiest way to search records in Clojure -


i have map in clojure this:

(def stuff #{          {:a "help" :b "goodbye"}         {:c "help2" :b "goodbye"}         {:a "steve" :b "goodbye"}         {:c "hello2" :b "sue"}     }) 

: , want provide search that:

(search stuff "help") 

: return :

 #{     {:a "help" :b "goodbye"}     {:c "help2" :b "goodbye"} } 

: simplest way this?

user=> (defn search [s q] (select #(some (partial re-find (re-pattern q)) (vals %)) s)) #'user/search user=> (search stuff "help") #{{:a "help", :b "goodbye"} {:c "help2", :b "goodbye"}} 

this trick.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -