3 ms·
There is a lot less of the unrestrained use of mutability in Clojure, but you can still have shared mutable references via atoms and refs. EDIT: As an example
by mej10 12y ago
There is a lot less of the unrestrained use of mutability in Clojure, but you can still have shared mutable references via atoms and refs.
EDIT:
As an example, here is the block-scanner in Clojure:
(defn block-scanner [trig]
(let [curr (atom trig)]
(fn [data]
(doseq [c data]
(if (not (empty? @curr))
(reset! curr
(if (= (first @curr) c)
(rest @curr)
trig))))
(empty? @curr))))