[racket] Exiting a for loop early

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Jul 19 20:37:20 EDT 2011

On Tue, Jul 19, 2011 at 8:24 PM, Justin Zamora <justin at zamora.com> wrote:
> Is there a built in way to exit the various kinds of for loops early?
> I've been using code like:
> (let/ec break
>  (for ([i (in-range 1 100)]
>        #:when (condition? i))
>         (break i))))
> Is there a better way?
> Justin

It sounds like you want the stop-before and stop-after functions, or
possibly the for/first loop.



Posted on the users mailing list.