Alex Krycek <krycek@sympatico.ca> wrote:
+---------------
| Is there any way to program a while or do..while loop with MzScheme?
+---------------
Well, you *can*, using macros, but given that the standard Scheme
"do" with no iteration variables:
(do () (TEST) BODY...)
is exactly the same as:
(while TEST BODY...)
I usually don't bother with "while" per se. Besides, you almost
always need local iteration variables in a loop, and "do" handles
that for you nicely.
Likewise, "do BODY... while TEST" can be written in standard
Scheme as:
(let loop ()
BODY...
(when TEST (loop)))
I usually don't bother with "do-while", either. Though YMMV...
-Rob
p.s. But if you really *insist* on "while" in MzScheme, try this:
(define-macro while
(lambda (test . body)
`(do () (,test) ,@body)))
-----
Rob Warnock, 8L-846 rpw3@sgi.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. FAX: 650-933-0511
Mountain View, CA 94043 PP-ASEL-IA