Search code examples
clojurespecter

Clojure Specter: how to find map keys that have specific value?


Eg in a map:

{"test-1" 23,
 "test-2" 456,
 "test-3" 23}

How to find keys that have value 23?


Solution

  • If you want to find something using Specter, it is better to use specter/select.

    (use 'com.rpl.specter)    
    
    (select [ALL #(= (second %) 23) FIRST]
      {"test-1" 23,
       "test-2" 456,
       "test-3" 23})