Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In LISP, code the macro, SELECT, which uses the following syntax: (select expr (when ( valueList1 ) ( stmt11 ) ... ( stmt1N ) )

In LISP, code the macro, SELECT, which uses the following syntax:

(select expr

(when (valueList1)

(stmt11)

...

(stmt1N) )

(when (valueList2)

(stmt21)

...

(stmt2N) )

...

(default

(stmtd1)

(stmtd2)

...

(stmtdN) ) )

Example:

(select grade

(when (A B)

(setf good (+ 1 good))

(print "doing well")

)

(when (C)

(print "average")

)

(when (D F)

(setf bad (+ bad 1))

(print "oh no")

)

(default

(print (list "unknown value=" grade))

)

)

If the value of expr matches a value in a valueList, each of the corresponding stmt expressions are executed (i.e., eval). The result of the select would be the last stmtn executed.

If the value of expr didn't match a value in any of the valueList and a default is provided, each of the stmt(s) corresponding to the default are executed. The result of the select would be the last stmtn executed.

If the value of expr didn't match a value in any of the valueList and a default is not provided, switch should return NIL.

Note that the values in each valueList are not evaluated.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions