RosettaCodeData/Task/History-variables/Clojure/history-variables.clj

4 lines
184 B
Clojure
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(def a (ref 0))
(def a-history (atom [@a])) ; define a history vector to act as a stack for changes on variable a
(add-watch a :hist (fn [key ref old new] (swap! a-history conj new)))