-
-
Save metamorph/ceda1cc0a97cde08cf04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"}) | |
Author
metamorph
commented
Oct 8, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment