Question: Using the programming language LISP: Code the macro, iterate, which is based on the following: (iterate controlVariable beginValueExpr endValueExpr incrExpr bodyexpr1 bodyexpr2 bodyexprN) .iterate is

Using the programming language LISP:

Using the programming language LISP: Code the macro, iterate, which is based

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 value of iterate will be T You can create an intermediate variable named endValue for the endValueExpr. You can create an intermediate variable named incValue for the incrExpr. name of those two variables. For 2 points bonus, use gensym to generate the Examples 1. (iterate i 1 5 1 (print (list one i)) one (one one one 4 one 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 value of iterate will be T You can create an intermediate variable named endValue for the endValueExpr. You can create an intermediate variable named incValue for the incrExpr. name of those two variables. For 2 points bonus, use gensym to generate the Examples 1. (iterate i 1 5 1 (print (list one i)) one (one one one 4 one

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!