Code the Macro, Iterate - IT Assignment Help

Download Solution Order New Solution
Assignment Task

 

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.
The "T" printed at the end of each of these is irrelevant. Yours can print "NIL" or nothing, doesn't matter.

Examples:
1. > (iterate i 1 5 1
(print (list 'one i))
)
(one 1)
(one 2)
(one 3)
(one 4)
(one 5)
T
2. > (setf n 5)
5
> (iterate i 1 n 1
(print (list 'two i n))
(+= i 1)
)
(two 1 5)
(two 3 5)
(two 5 5)
T
3. > (setf n 5)
5
> (iterate i 1 n 1
(print (list 'three i n))
(+= n 1)
)
(three 1 5)
(three 2 6)
(three 3 7)
(three 4 8)
(three 5 9)
T
4. > (setf n 5)
5
> (setf inc 2)
2
> (iterate i 1 n inc
(print (list 'three i n inc))
(+= inc 1)
)
(three 1 5 2)
(three 3 5 3)
(three 5 5 4)
T

 

This IT Assignment has been solved by our IT experts at My Uni Papers. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.