femtolisp/tests/wt.lsp

29 lines
565 B
Plaintext
Raw Normal View History

(define-macro (while- test . forms)
2008-06-30 21:54:22 -04:00
`((label -loop- (lambda ()
(if ,test
(begin ,@forms
2008-06-30 21:54:22 -04:00
(-loop-))
())))))
(define (tw)
(set! i 0)
(while (< i 10000000) (set! i (+ i 1))))
(define (tw2)
(letrec ((loop (lambda ()
(if (< i 10000000)
(begin (set! i (+ i 1))
(loop))
()))))
(loop)))
#|
interpreter:
while: 1.82sec
macro: 2.98sec
compiler:
while: 0.72sec
macro: 1.24sec
|#