Skip to content

Instantly share code, notes, and snippets.

@dominem
Created March 22, 2020 15:52
Show Gist options
  • Save dominem/14ba93be3916f7e5f3dca094f3def3c0 to your computer and use it in GitHub Desktop.
Save dominem/14ba93be3916f7e5f3dca094f3def3c0 to your computer and use it in GitHub Desktop.
(defn my-update-in
[m ks f & args]
(assoc-in m ks (apply f (cons (get-in m ks) args))))
(comment
(my-update-in {:author {:name "Dominik"}} [:author] vec)
;; => {:author [[:name "Dominik"]]}
(my-update-in {:author {:name "Dominik"}} [:author :name] str " Magdalenski")
;; => {:author {:name "Dominik Magdalenski"}}
(my-update-in {} [:author :name] str " Magdalenski")
;; => {:author {:name " Magdalenski"}}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment