[plt-scheme] a simple macro

From: michael rice (nowgate at yahoo.com)
Date: Tue Nov 21 18:59:22 EST 2006

Here's a macro that uses a user defined function in
its expansion. It works fine in Common Lisp but I
think I had a problem with it in an earlier version of
DrScheme. If I remember right I exchanged some emails
with Matt Flatt who said at the time that the macro
system needed some work.

How would one write the macro mac in Scheme?

(defun fun (n) (cond ((zerop n) nil) (t (cons n (fun
(- n 1))))))

(defmacro mac (n) `(+ ,@(fun n)))

(fun 6) => (6 5 4 3 2 1)
(mac 6) => 21

Michael


 
____________________________________________________________________________________
Sponsored Link

Online or Campus degree Associate's, Bachelor's, or Master's
in less than one year.www.findtherightschool.com


Posted on the users mailing list.