scsh-users
[Top] [All Lists]

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

To: scsh-users@scsh.net
Subject: Re: `break' to jump out of a loop ?
From: Michael Sperber <sperber@informatik.uni-tuebingen.de>
Date: Fri, 10 Jun 2005 08:26:03 +0200
List-id: <scsh-users.list-id.scsh.net>
"Rick Hanson" <rick@tamos.net> 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" <rick@tamos.net> 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

<Prev in Thread] Current Thread [Next in Thread>