Closed jackfirth closed 2 years ago
Saw this code today:
(let loop ([i (sub1 (vector-length p))]) (and (>= i 0) (let ([gs (vector-ref p i)]) (if (term? gs) (term-prec gs) (loop (sub1 i))))))
That code is equivalent to this:
(for/first ([gs (in-vector p (sub1 (vector-length p)) -1 -1)] #:when (term? gs)) (term-prec gs))
There's some variants of this pattern that are also worth capturing, such as:
Saw this code today:
That code is equivalent to this:
There's some variants of this pattern that are also worth capturing, such as: