While loops for Racket
1 Example and usage
while
break
continue
7.0

While loops for Racket

This basically provides while, break and continue.

1 Example and usage

 (require dyoo-while-loop) package: while-loop

#lang racket/base
(require dyoo-while-loop)
 
(while (not (string=? (read-line)
                      "quit"))
  (printf "quit?  "))
 
(while #t
  (define input (read-line))
  (unless (regexp-match #px"please" input)
    (printf "You didn't say please\n")
    (continue))
  (when (regexp-match #px"quit" input)
    (break)))

syntax

(while test body ...)

Repeat the evaluation of the body so long as test is true.

syntax

(break)

Break out of the innermost loop.

syntax

(continue)

Restart the innermost loop.