Re: `break' to jump out of a loop ?
"Rick Hanson" <[email protected]> Thu, 9 Jun 2005 16:20:34 -0400 (EDT)
| Newsgroups | gmane.lisp.scheme.scsh |
|---|---|
| Message-ID | <[email protected]> |
> Hi, there,
>
> Is there a `break' thing to jump out of a loop, such as in an awk macro?
>
> --
> William
>
>
I think the "standard way" is to use call/cc (although I'm not an expert).
Excuse my old version of scsh:
$ cat > test1.scsh
(define call/cc call-with-current-continuation)
(define (test1)
(let loop0 ((x 1))
(call/cc
(lambda (k)
(let loop1 ((y x))
(if (= y 5)
(k y)
(loop1 (+ y 1))))))))
^D
$ scsh
Welcome to scsh 0.6.4 (Olin Shivers)
Type ,? for help.
> (load "test1.scsh")
test1.scsh
> call/cc
'#{Procedure 1322 (call-with-current-continuation in wind)}
> (test1)
5