Forgive the extremely contrived example, but how common is this sort of thing: (for*/fold ([res '()]
#:result res)
([elem (in-range 10)]
[elem-str (in-value (number->string elem))])
(values (cons elem-str res)))
that is, using in-values in combination with a for* form to achieve let-like bindings as part of the for clauses? I used to really dislike having to wrap the body in another let to establish bindings when there’s a perfectly good binding form already. Is this a common idiom?
@sydney.lambda two things — first, you want to use in-value
around the (number->string ...)
to get it to work right. second, it’s reasonably common, that’s why in-value
exists. third, you can just use (define elem-str ...)
in the body in that example. fourth, you don’t need the #:result
clause there, since it’s just res
@samth sorry, I completely forgot the in-value in the code which was the whole point. That wasn’t the best example as you mentioned, but I’m glad you saw what I was trying to get at, thanks. It was mentioned in general and I just wanted to make sure I was understanding it correctly.