Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement an enum facility as a Common Lisp macro , defenum, to add functionality similar to Java's enum types. Specfically, the following shows the code

Implement an enum facility as a Common Lisp macro, defenum, to add functionality similar to Java's enum types.

Specfically, the following shows the code expansion of the defenum macro with various arguments. Your defenum must macroexpand to exactly the same code expansion. For this assignment, you are not allowed to use any iteration constructs in your code.

(macroexpand '(defenum (day number) (Sunday 0) (Monday 1) (Tuesday 2) (Wednesday 3) (Thursday 4) (Friday 5) (Saturday 6))) (PROGN (DEFCONSTANT DAY->NUMBER->SUNDAY 0) (DEFCONSTANT DAY->NUMBER->MONDAY 1) (DEFCONSTANT DAY->NUMBER->TUESDAY 2) (DEFCONSTANT DAY->NUMBER->WEDNESDAY 3) (DEFCONSTANT DAY->NUMBER->THURSDAY 4) (DEFCONSTANT DAY->NUMBER->FRIDAY 5) (DEFCONSTANT DAY->NUMBER->SATURDAY 6) (LET ((DAY->NUMBER '((0 . SUNDAY) (1 . MONDAY) (2 . TUESDAY) (3 . WEDNESDAY) (4 . THURSDAY) (5 . FRIDAY) (6 . SATURDAY)))) (DEFUN DAY->NUMBER (NUMBER) (CDR (ASSOC NUMBER DAY->NUMBER)))))

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: 3

blur-text-image

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Has the priority order been provided by someone else?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago