How do I return from a function before reaching the last form in standard Racket? That can be useful to avoid another level of indentation and form nesting.
In Common Lisp there is return, a specialized form of return-from. Any equivalent in Racket, at least for return only?
Use let/ec
to create an escape continuation.
Example:
(let/ec return
(for ([x 10000])
(when (= x 100)
(return x))))
Using let/ec is cheaper than using call/cc which creates a full continuation.
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