(define-macro arith-if
(lambda (test-val neg-branch zero-branch pos-branch)
`(cond ((< ,test-val 0) ,neg-branch)
((= ,test-val 0) ,zero-branch)
((> ,test-val 0) ,pos-branch))))
Next is a for loop from Pascal or BASIC (without a step option).
(define-macro p-for
(lambda (counter start limit . body)
`(let loop ((,counter ,start))
(when (<= ,counter ,limit)
,@body
(loop (+ ,counter 1))))))
No comments:
Post a Comment