#lang scribble/manual @(require (for-label racket "main.rkt")) @(require "main.rkt" planet/scribble) @title{Structured Loops} @(defmodule/this-package main) @defform*[#:literals (or then) [(until condition body ...) (until (or (alternative-condition then result ...) ...) body ...)]]{ First form: check @racket[condition], repeating @racket[body] until the condition is true, i.e. while it's false. The result is the value of @racket[condition]. Second form: the disjunction of the @racket[alternative-condition]s is used as the condition --- i.e. loop until at least one of the @racket[alternative-condition]s is true. The result is the value of the (first one's) corresponding @racket[result ...] . } @defform*[#:literals (and else) [(while condition body ...) (while (and (sub-condition else result ...) ...) body ...)]]{ First form: check @racket[condition], repeating @racket[body] while the condition is true, i.e. until it's false. The result is false. Second form: the conjunction of the @racket[sub-condition]s is used as the condition --- i.e. loop until at least one of the @racket[alternative-condition]s is false. The result is the value of the (first one's) corresponding @racket[result ...]. } @deftogether[[(defproc (continue) any) (defproc (break (v any void)) any)]]{Within the body of an @racket[until] or @racket[while] form, calling @racket[continue] ends the current iteration and tries (by checking the condition first) the next iteration. Calling @racket[break] ends the loop using @racket[v] as the loop's result (defaulting to @void-const). Use outside the body of an @racket[until] or @racket[while] form is a syntax error.}