Exercises: preamble On Portacle, type C-x C-f to create a new file solution.lisp in your Lab03/...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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) 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)
Expert Answer:
Answer rating: 100% (QA)
On Portacle type Cx Cf to create a new file solutionlisp in a folder and copypaste the program be... View the full answer
Related Book For
Using Microsoft Excel and Access 2016 for Accounting
ISBN: 978-1337109048
5th edition
Authors: Glenn Owen
Posted Date:
Students also viewed these american history questions
-
Write Emacs Lisp scripts to (a) Insert todays date into the current buffer at the insertion point (current cursor location). (b) Place quote marks (" ") around the word surrounding the insertion...
-
Lisp began as a pure functional language but gradually acquired more and more imperative features. Why?
-
What happens during the reader phase of a Common Lisp language processor?
-
Consider the following limit order book for a stock.The last trade in the stock occurred at a price of $55. Buy Order Limit Sell Order Limit Precio share Precio share ps 54.75 500 ps 55.25 200 54.50...
-
It is estimated that next year hourly wage rates will increase by 7 percent and productivity will increase by 5 percent. What would you expect to happen to unit labor cost? Discuss how this unit...
-
For each of the following categories, describe some of the difficulties that you would face in estimating appropriate values to be used in conducting an economic analysis. a. Cash flows b. MARR c....
-
The Foreign Corrupt Practices act can levy fines of more than five hundred million against companies our size that do not eliminate corruption in their operations abroad. Can you understand why the...
-
Markel Corporation's balance sheet at December 31, 2011, is presented below. During 2012, the following transactions occurred.1. Markel paid $2,500 interest on the bonds on January 1, 2012.2. Markel...
-
The current in the 1 3 . 8 2 resistor is / 3 = 0 . 9 A . 1 . Find the current in the other resistors in thecircuit? 2 . What is the total energy dissipated in resistor 4 1 7 . 2 0 if the power supply...
-
City Bank issued $200 million of one-year CDs in the United States at a rate of 6.50 percent. It invested part of this money, $100 million, in the purchase of a one-year bond issued by a U.S. firm at...
-
The Pension Funds Act introduced the Clean Break Principle in 2007, which deals with the distribution of retirement benefits in terms of a divorce settlement. Indicate the incorrect answer from each...
-
As a general rule, shareholders are not personally responsible for the debts of the corporation. (True/False)
-
To be valid, a financing statement does not need to contain a description of the collateral. (True/False)
-
General Manufacturing, Inc. (GMI), issues bonds to finance the purchase of a factory. Regarding those bonds, which of the following is true? a. The bonds must be repaid. b. The bondholders will...
-
Infinity Credit LLC makes loans to consumers secured by their homes. An Infinity Credit loan is an adjustable-rate mortgage if its interest rate a. adjusts periodically. b. changes with the consumers...
-
What is an automatic stay?
-
Two iron samples with different grain sizes are tensile tested. The grain size of sample A is 0.37 um and the grain size of sample B is 1.10 m. (a) Sketch stress-strain curves of both samples on the...
-
On August 31, 2012, the balances of the accounts appearing in the ledger of Wood Interiors Company, a furniture wholesaler, are as follows:Prepare the August 31, 2012, closing entries for Wood...
-
Compare the percent of sales and aging methods of determining uncollectible accounts expense and the ending allowance for the uncollectible accounts balance.
-
Modify What SUPs Straight-Line Depreciation Schedule You are to add another depreciation schedule for What SUP. Use the ch4-01_SLN_student_name.xls worksheet you created in this chapter. Add a new...
-
When might you use a delete query?
-
What stakeholder affected by their behavior was Gilead weighting very lightly when it decided what to tell the FDA about the medicines it wished to have permission to sell?
-
James Lewis, a resident of Kentucky, sustained an injury while operating a Caterpillar bulldozer. He filed suit against Caterpillar, a company incorporated in Delaware but with its principal place of...
-
Two residents of California filed a lawsuit against Hertz Corporation on behalf of a group of people arguing that the companys labor practices were illegal. The corporation was labeling workers as...
Study smarter with the SolutionInn App