On Tue, Jul 19, 2011 at 8:24 PM, Justin Zamora <jus...@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. http://docs.racket-lang.org/reference/sequences.html?q=sequence#(def._((lib._racket/private/base..rkt)._stop-before)) http://docs.racket-lang.org/reference/sequences.html?q=sequence#(def._((lib._racket/private/base..rkt)._stop-after)) http://docs.racket-lang.org/reference/for.html?q=for/first&q=sequence#(form._((lib._racket/private/base..rkt)._for/first)) --Carl _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users