From 32a7765ac302ff48116c2978c5d33dd746c8a823 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 21 Jul 2016 16:58:28 -0700 Subject: [PATCH] tighten --- beautiful-racket/br/demo/stacker.rkt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/beautiful-racket/br/demo/stacker.rkt b/beautiful-racket/br/demo/stacker.rkt index 3c8a45a..d68624a 100644 --- a/beautiful-racket/br/demo/stacker.rkt +++ b/beautiful-racket/br/demo/stacker.rkt @@ -1,9 +1,9 @@ #lang br/quicklang -(define (read-syntax src-path in-port) - (define args (port->list read in-port)) +(define (read-syntax path port) + (define args (port->lines port)) (define arg-datums (format-datums '(handle ~a) args)) - (define module-datum `(module mod-name br/demo/stacker + (define module-datum `(module stacker-mod br/demo/stacker ,@arg-datums)) (datum->syntax #f module-datum)) (provide read-syntax) @@ -24,10 +24,10 @@ (define (push-stack! item) (set! stack (cons item stack))) -(define (handle arg) +(define (handle [arg #f]) (cond [(number? arg) (push-stack! arg)] - [else + [(procedure? arg) (define op-result (arg (pop-stack!) (pop-stack!))) (push-stack! op-result)]))