Skip to content

Instantly share code, notes, and snippets.

@noahlz
Created December 29, 2011 04:04
Show Gist options
  • Save noahlz/1531791 to your computer and use it in GitHub Desktop.
Save noahlz/1531791 to your computer and use it in GitHub Desktop.
LabREPL Unified update model notes and exercises
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Atoms
;; Using swap! and merge-with on a map
;; the trick is to put merge-with inside a function.
(def m (atom {:a 1}))
;=> #'user/m
user> (swap! m #(merge-with + % {:a 2}))
;=> {:a 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment