Skip to content

Commit

Permalink
e/with-cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
dustingetz committed Sep 3, 2024
1 parent 65ca6ed commit 6027191
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/hyperfiddle/electric3.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ this tuple. Returns the concatenation of all body results as a single vector.
~(rec bindings)) `(do ~@body)))
(seq bindings))))

(defmacro with-cycle
"evaluates body with symbol s bound to the previous result of the body evaluation.
the first evaluation binds s to i."
{:style/indent 1}
[[s i] & body]
`(let [a# (atom ~i) ~s (watch a#)]
(reset! a# (do ~@body))))

;; mklocal = declare lexical slot
;; bindlocal = bind lexical slot to value by name
;; See compiler walkthrough: electric/impl/lang_3_walkthrough.md
Expand Down

0 comments on commit 6027191

Please sign in to comment.