Thanks Bill, yes that was it. I had figured out that was the (first!) error before you replied, but my solution was much more rube-goldbergish than yours, so much appreciated.
Of course now I've realized it needs to be recursive, silly me. (+ %1 %2) works, but not (+ (+ %1 %2) %3). gah! iain On Wed, Sep 8, 2021 at 10:09 AM <[email protected]> wrote: > I think the "sexp" argument to map is just the > macro argument name 'sexp, so map can't figure > out what to do, and asks make-iterator to do > something (hence the make-iterator error). I > would write the macro: > > (define-macro (run-expr sexp) > `(eval (map > (lambda(token) > (if (and (symbol? token) > (eq? ((symbol->string token) 0) #\%)) > `(s4m-expr-inputs ,(string->number (substring > (symbol->string token) > 1))) > token)) > ,sexp)) > > so (s4m-run-expr "(+ %1 %2 %3)") returns 66. > > If you omit the eval (to see what code is being generated), > > (s4m-run-expr "(+ %1 %2 %3)") > > returns > > (+ (s4m-expr-inputs 1) (s4m-expr-inputs 2) (s4m-expr-inputs 3)) > >
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
