update stacker source

pull/2/head
Matthew Butterick 8 years ago
parent 7d5a6d45a5
commit 68922b0cb5

@ -8,10 +8,10 @@
(datum->syntax #f module-datum)) (datum->syntax #f module-datum))
(provide read-syntax) (provide read-syntax)
(define-macro (stacker-module-begin DATUM-STX ...) (define-macro (stacker-module-begin HANDLE-EXPR ...)
#'(#%module-begin #'(#%module-begin
DATUM-STX ... HANDLE-EXPR ...
(display (pop-stack!)))) (display (first stack))))
(provide (rename-out [stacker-module-begin #%module-begin])) (provide (rename-out [stacker-module-begin #%module-begin]))
(define stack empty) (define stack empty)
@ -27,11 +27,12 @@
(define (handle [arg #f]) (define (handle [arg #f])
(cond (cond
[(number? arg) (push-stack! arg)] [(number? arg) (push-stack! arg)]
[(procedure? arg) [(or (equal? * arg) (equal? + arg))
(define op-result (arg (pop-stack!) (pop-stack!))) (define op-result (arg (pop-stack!) (pop-stack!)))
(push-stack! op-result)])) (push-stack! op-result)]))
(provide handle)
(provide handle + *) (provide + *)
(module+ test (module+ test
(require rackunit) (require rackunit)

Loading…
Cancel
Save