[plt-scheme] A couple of macro questions

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Tue Nov 24 08:46:58 EST 2009

I just started working through Dybvig's _The Scheme Programming
Language_ (which I found by re-reading previous posts that were
answers to "How do I learn Scheme?" Don't know how I missed it the
first several times it was suggested, but the explanation of macros
and stuff has been very nice.) and have a couple of questions.

1. I tried for a long time to define let* using only a single pattern,
but couldn't. Using two patterns was pretty easy. I don't want to put
my code up here since it's an exercise, but am I right that you need a
0-assignment pattern and a 1-or-more-assignment pattern for the
ellipses to work correctly?

2. Is there a function in Scheme that does partial simplification, say
to core elements or that does the equivalent of one step in the
stepper? I'm looking for something like:

> (core (my-let* ([a 5] [b (* 2 a)] [c (+ b 5)]) (list a b c))))
((lambda (a)
  ((lambda (b)
    ((lambda (c)
      (list a b c)) (+ b 5))
    (* 2 a))
> (step (+ (* 2 3) 7))
(+ 6 7)

In other words, I guess, are the functions that the Stepper and Macro
Stepper call available in the REPL?


Posted on the users mailing list.