What is the idiomatic way to create an infinite loop?
while(true){
calc();
}
I want to call the calc function forever. Only one function is called over and over again.
EDIT: One other thing I forgot to mention is that calc has side effects. It does some calculations and modifies a byte array.
while
is in the core libraries.
(while true (calc))
This expands to a simple recur
.
(defmacro while
"Repeatedly executes body while test expression is true. Presumes
some side-effect will cause test to become false/nil. Returns nil"
[test & body]
`(loop []
(when ~test
~@body
(recur))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With