Skip to content

Instantly share code, notes, and snippets.

@metamorph
Created October 8, 2014 21:07
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 metamorph/ceda1cc0a97cde08cf04 to your computer and use it in GitHub Desktop.
Save metamorph/ceda1cc0a97cde08cf04 to your computer and use it in GitHub Desktop.
(def data [{:id "foo" :name "Foo" :auth_token "f1"}
{:id "bar" :name "Bar" :auth_token "b1"}
{:id "zip" :name "Zip" :auth_token "z1"}])
(defn prepare-accounts
"Removes the account that has the :id value of the provided param, and
also removes the key-value pair :auth_token from all accounts"
[accounts unwanted-id]
(->> accounts
(map #(dissoc % :auth_token))
(remove #(= unwanted-id (:id %)))))
(prepare-accounts data "bar")
;; Expected: ({:name "Foo", :id "foo"} {:name "Zip", :id "zip"})
@metamorph
Copy link
Author

(for [d data :when (not= unwanted-id (:id d)] (dissoc d :auth_token))

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