Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created June 1, 2015 18:09
Show Gist options
  • Save defHLT/65811e88651e846c79bb to your computer and use it in GitHub Desktop.
Save defHLT/65811e88651e846c79bb to your computer and use it in GitHub Desktop.
7 user=> (def get-prev-and-set (let [a (atom {})] (fn [x] (let [r (@a :a)] (swap! a assoc :a x) r))))
6 #'user/get-prev-and-set
5 user=> (get-prev-and-set 1)
4 nil
3 user=> (get-prev-and-set 123)
2 1
1 user=> (get-prev-and-set 42)
8 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment