
laurent.orseau
2022-2-10 09:42:16
i’m a bit confused by #:break
in for/fold
clauses: > (for/fold ([res 0])
(#:break (= res 5)
[i (in-range 10)])
(display i)
i)
01234567899
> (for/fold ([res 0])
([i (in-range 10)]
#:break (= res 5))
(display i)
i)
0123455
I was expecting the first case to break before i
would be bound.

mflatt
2022-2-10 13:26:57
A #:break
is like a #:when
in that creates nested iteration (in the for*
sense) for anything after it. So, your first example is similar to #:when #t
: it’s only checked once before the i
iteration starts.

laurent.orseau
2022-2-10 13:56:22
I see, thanks. Would it be useful if i add this example to the docs? Or maybe would it make sense to disallow #:break
before any clause?

rokitna
2022-2-10 19:34:36
›...‹
indeed :)