Programming Homework Help

CS 3723 The University of Texas at San Antonio LISP Programming

 

Code the macro, iterate, which is based on the following:

(iterate controlVariable beginValueExpr endValueExpr incrExpr bodyexpr1 bodyexpr2 … bodyexprN)

  • iterate is passed a controlVariable which is used to count from beginValueExpr to endValueExpr (inclusive) by the specified increment.
  • For each iteration, it evaluates each of the one or more body expressions.
  • Since beginValueExpr,endValueExpr, and incrExpr are expressions, they must be evaluated.
  • The endValueExpr and incrExpr are evaluated before processing the rest of the macro.This means the code within the user’s use of the macro cannot alter the termination condition nor the increment; however, it can change the value of the controlVariable.
  • The functional return value of iterate macro doesn’t matter, and will probably be T.
  • You can create an intermediate variable named endValue for the endValueExpr. You can create an intermediate variable named incValue for the incrExpr. For 5 bonus points, use gensym to generate the name of those two variables.