Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercises: preamble On Portacle, type C-x C-f to create a new file solution.lisp in your Lab03/ folder, and copy-paste the program below in your
Exercises: preamble On Portacle, type C-x C-f to create a new file solution.lisp in your Lab03/ folder, and copy-paste the program below in your solution.lisp. To copy-paste text to a window buffer in emacs on Portacle: use the cursor to highlight the text, then click on the location you would like to paste the text, and press C-y (defstruct movie title director year type) (defparameter *size* 3) (defvar *db*) (setf *db* (make-array *size* :initial-element nil)) (defun add-movie (m) "Adds a movie to *db* and returns *db*" (dotimes (i *size*) (when (null (aref *db* i)) (setf (aref *db* i) m) (return *db*)))) (defun in-db? (title) "Returns *db* if movie title is in the database; otherwise returns NIL" (dotimes (i *size*) (when (and (typep (aref *db* i) 'movie) (equal (movie-title (aref *db* i)) title)) (return *db*)))) In the exercises below, you will be asked to change function ADD-MOVIE and add other functions to this program. NOTE: you should not change the definition of the structure MOVIE provided above when solving these exercises. Exercise 1 Preamble Function ADD-MOVIE above adds a movie to the *db* and returns *db*. What you are asked Change function ADD-MOVIE so that it returns NIL if the database is already full. Also, if the movie title is already in the database, it returns NIL. Otherwise it adds the movie to the database and returns the array. See more examples by typing on the REPL CL-USER> (show-test-cases :lab03 'test-add-movie)
Step by Step Solution
★★★★★
3.40 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
On Portacle type Cx Cf to create a new file solutionlisp in a folder and copypaste the program be...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started