1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- (import
- (scheme base)
- (scheme read)
- (scheme write))
- (define-syntax function
- (syntax-rules ()
- ((_ (proc args ...) body ...)
- (define (proc args ...) body ...))))
- (define-syntax var
- (syntax-rules ()
- ((_ (sym val))
- (define sym val))
- ((_ sym)
- (define sym #f))
- ((_ first rest ...)
- (begin
- (_ first)
- (_ rest ...)))))
- (define-syntax while
- (syntax-rules ()
- ((_ pred body ...)
- (let loop ()
- (when pred
- (begin body ...)
- (loop))))))
- (define-syntax for
- (syntax-rules ()
- ((_ (init pred inc) body ...)
- (begin
- init
- (let loop ()
- (when pred
- (begin body ...)
- inc
- (loop)))))))
- (define-syntax =!
- (syntax-rules ()
- ((_ a b)
- (set! a b))))
- (define-syntax ++
- (syntax-rules ()
- ((_ i)
- (set! i (+ i 1)))))
- (define-syntax *=
- (syntax-rules ()
- ((_ a b)
- (set! a (* a b)))))
|