Skip to content

Instantly share code, notes, and snippets.

@celwell
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save celwell/552318c5c08fc5a2bff2 to your computer and use it in GitHub Desktop.
Save celwell/552318c5c08fc5a2bff2 to your computer and use it in GitHub Desktop.
(-> test-results
(->> (map #(list (:id %) (:prefill_config %))))
flatten
(->> (apply hash-map))
keywordize-keys
(select-keys (map keyword current-form-ids)))
@celwell
Copy link
Author

celwell commented Jul 29, 2014

Example INPUT:

(def test-results '({:id "bock-chow" :prefill_config "sdf hjksd fhjksdhfjk"}
                          {:id "took-cow" :prefill_config "ffffsdfsdf hjksd fhjksdhfjk"}
                          {:id "djjd-djd" :prefill_config "sdf hjksd fhjksdhfjk"}))
(def current-form-ids '("bock-chow" "took-cow"))

Example OUTPUT:

{:took-cow "ffffsdfsdf hjksd fhjksdhfjk", :bock-chow "sdf hjksd fhjksdhfjk"}

@celwell
Copy link
Author

celwell commented Jul 31, 2014

Ended up with:

(->> test-results
     (filter #(contains? (set current-form-ids) (:id %)))
     (mapcat (juxt (comp keyword :id) :prefill_config)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment