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...
-
Marshall defined an equilibrium price as one at which the quantity demanded equals the quantity supplied. a. Using the data provided in problem 1.1, show that P = 3 is the equilibrium price in the...
-
Set up the opportunity loss table from the following payoff table: 26 55 38 43 S2 43 29 $3 51 15 54
-
If you are preparing a client for a deposition, what rules for responding to deposition questions should you review with the client?
-
Plato Energy is an oil and gas exploration and development company located in Farmington, New Mexico. The company drills shallow wells in hopes of finding significant oil and gas deposits. The firm...
-
3. Markov analysis The training program for production supervisors at a particular company consists of twophases. Phase 1, which involves 3 weeks of classroom work, is followed by phase 2, which is a...
-
New Horizons Co. is a high-tech firm whose owner does not have the required management expertise to run the firm. The owner wants to hire a manager with the required expertise. The continued success...
-
The Zeeman Effect can be observed by applying a magnetic field on the atomic discharged beam of a mercury lamp. Consider the three-level atoms of the following configurations, c) (a) V-type atom ()...
-
Calculate Cash flow from Operating activities Net income: $90 No non cash adjustments: $0 Net cash flow from operating activities: $90 2) Prepare the 2020 statement of changes in equity Common stock...
-
A US treasury bond, issued on 11/15/2016, will expire on 11/15/2026. As of 2/1/2017, this bond is yielding 2.84% and is trading at a clean (or flat) price of 95.00 1. What is the coupon of this bond?...
-
With a selling price of $88,000, a down payment of $24,000, and a mortgage at 5% for 30 years, calculate the total cost of interest.
-
The firm's current beta is 1.0, and the current T. Bond rate is 8.5%. The firm expects working capital to increase $50 million both this year and next. The firm plans to finance its net capital...
-
What is a budget? How does revenue relate to a budget? Explain two consequences of having revenue being too far from budget. Why is it better to use percentages for revenue performance instead of...
-
create a story that goes along with your sentence. the topic is I got scammed you are the protagonist. #2 is where you meet your antagonist, #4 is where your antagonist causes you to change.... 1....
-
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?
-
Ethyl alcohol and hexane form an azeotrope containing \(33.2 \mathrm{~mol}\) per cent ethanol at \(58.7^{\circ} \mathrm{C}\) and \(1 \mathrm{~atm}\) pressure. Determine the van Laar parameters at...
-
For the binary system \(n\)-pentanol (1)- \(n\)-hexane (2), determine the activity coefficients at \(31 \mathrm{~K}\) in an equimolar mixture. The Wilson parameters are as follows: \[ \begin{aligned}...
-
n-heptane and toluene form an ideal solution mixture. At \(373 \mathrm{~K}\), their vapour pressures are \(106 \mathrm{kPa}\) and \(74 \mathrm{kPa}\) respectively. Determine the composition of the...
5 Steps To A 5 AP Spanish Language And Culture 2020-2021 2021 Edition - ISBN: 1260456706 - Free Book
Study smarter with the SolutionInn App