While Loop Macro in DrRacket

前端 未结 4 1498
野性不改
野性不改 2020-12-11 20:49

I am trying to create a macro for while loop in DrRacket. Here is what I wrote:

(require mzlib/defmacro)

(define-macro my-while
  (lambda (condition  body)
         


        
4条回答
  •  Happy的楠姐
    2020-12-11 21:45

    Another version of while uses a do loop:

    (define-syntax while
      (syntax-rules ()
        ((while pred? stmt ...)
          (do () ((not pred?))
            stmt ...))))
    

提交回复
热议问题