Pgm3 Lisp Macros Code the macros listed below and use the specified test cases.
ID: 3602992 • Letter: P
Question
Pgm3 Lisp Macros Code the macros listed below and use the specified test cases. Notes: Using Lisp Only hint: MEMSET returns T if an atom is a member in a set (at the top-level) > (defun MEMSET (atm L) (cond (NULL L) NIL) ( (EQL atm (CAR L)) T) (T (MEMSET atm (CDR L))) (memset 'x '(x y z)) is T (memset 'w'x y z) is NIL 1. code the macro, , which is passed a variable which it decrements by the decremenvaue and assigns the new value. The function value returned by-should be the new value of numericVariable (-= numericVariable decrementva Lue) Example: > (setf x 5) > (-= x 1) 4 4 CLISP sometimes gives an error like the following when you LOAD a file with that macro definition: PACKAGE COMMON-LISP> is locked f you continue (by typein cotine):Ignore the lock and proceed To ignore that message, simply type CONTINUEExplanation / Answer
Pattern-Based Macros Most popular API for macros: patterns #define swap(x, y) (tmp=y, y=x, x=tmp) swap(c.red, d->blue) (tmp=d->blue, d->blue=c.red, c.red=tmp) + Relatively easy for programmers to understand + Obvious hook into the tool chain - Pure patterns can't easily express much Macros In General Pattern-Based Macros Scheme macro basics Extended Example Lexical Scope General Transformers State of the Art
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.