revise
parent
fc1b5659ee
commit
bc47acd4d4
@ -0,0 +1,8 @@
|
|||||||
|
#lang reader br/demo/stacker3
|
||||||
|
4
|
||||||
|
8
|
||||||
|
|
||||||
|
+
|
||||||
|
3
|
||||||
|
|
||||||
|
*
|
@ -0,0 +1,24 @@
|
|||||||
|
#lang br/quicklang
|
||||||
|
#:read-syntax stacker-read-syntax
|
||||||
|
#:#%module-begin stacker-module-begin
|
||||||
|
|
||||||
|
(define (stacker-read-syntax src-path in-port)
|
||||||
|
(strip-context
|
||||||
|
#`(module stacker3-mod br/demo/stacker3
|
||||||
|
#,@(port->list read in-port))))
|
||||||
|
|
||||||
|
(define-macro (stacker-module-begin STACK-ARG ...)
|
||||||
|
#'(#%module-begin
|
||||||
|
(display
|
||||||
|
(first
|
||||||
|
(foldl (λ(arg stack)
|
||||||
|
(if (number? arg)
|
||||||
|
(cons arg stack)
|
||||||
|
(cons (arg (car stack) (cadr stack)) (cddr stack))))
|
||||||
|
null (list STACK-ARG ...))))))
|
||||||
|
|
||||||
|
(provide + *)
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(require rackunit)
|
||||||
|
(check-equal? (with-output-to-string (λ () (dynamic-require "stacker2-test.rkt" #f))) "36"))
|
Loading…
Reference in New Issue