More generally, the any define-values with for/fold expression can move the single "tail computation" expression into #:result and remove the wrapping define-values. It's worth doing this when the "tail computation" is simple.
That is indeed tricky. Got some examples of code in the wild this could clean up? Maybe we could get more mileage out of only detecting simpler cases, like when only one of the define-values bindings is used.
This one may be difficult, but might be worth trying.
Previously,
for/fold
doesn't support#:result
, so the code could look like this:But with
#:result
, we can simplify it to simply:More generally, the any
define-values
withfor/fold
expression can move the single "tail computation" expression into#:result
and remove the wrappingdefine-values
. It's worth doing this when the "tail computation" is simple.