Re: `break' to jump out of a loop ?

Michael Sperber <[email protected]> Fri, 10 Jun 2005 08:26:03 +0200
Newsgroups gmane.lisp.scheme.scsh
Message-ID <[email protected]>
"Rick Hanson" <[email protected]> writes:

> I think the "standard way" is to use call/cc (although I'm not an
> expert).

No.  NOOO.

The "standard way" to jump out of a loop is to write it using explicit
tail recursion, and just not jump back into it.

"Rick Hanson" <[email protected]> writes:

> (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))))))))

(define (test1)
  (let loop1 ((y 1))
    (if (= y 5)
	y
	(loop1 (+ y 1)))))

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla