Define your own Racket function that duplicates the the functionality of list-ref from the standard library....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Define your own Racket function that duplicates the the functionality of list-ref from the standard library. You may not use the built-in list-ref function as a helper function. Define a function that takes a list and an integer. The function should return the list element at the integer number (first list position is index "0"). If the integer is larger than the index of the last list member, it should display an "index out of bounds" message. Your implementation must be recursive. Input: A list of elements of any data type, potentially heterogenous, and a single integer. Output: A single element from the original list that is at the "index" indicated by the integer. The first list position is position "0", the second list position is "1", etc. If the integer is greater than the number of list elements, the function should throw an error (using the error function) with the message string "ERROR: Index out of bounds". Example: > (my-list-ref (479) 0) 4 > (my-list-ref (479) 1) 7 > (my-list-ref (479) 3) ERROR: Index out of bounds Define your own Racket function that duplicates the the functionality of list-ref from the standard library. You may not use the built-in list-ref function as a helper function. Define a function that takes a list and an integer. The function should return the list element at the integer number (first list position is index "0"). If the integer is larger than the index of the last list member, it should display an "index out of bounds" message. Your implementation must be recursive. Input: A list of elements of any data type, potentially heterogenous, and a single integer. Output: A single element from the original list that is at the "index" indicated by the integer. The first list position is position "0", the second list position is "1", etc. If the integer is greater than the number of list elements, the function should throw an error (using the error function) with the message string "ERROR: Index out of bounds". Example: > (my-list-ref (479) 0) 4 > (my-list-ref (479) 1) 7 > (my-list-ref (479) 3) ERROR: Index out of bounds
Expert Answer:
Related Book For
Accounting Information Systems
ISBN: 978-0133428537
13th edition
Authors: Marshall B. Romney, Paul J. Steinbart
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Write a static method max3() that takes three int arguments and returns the value of the largest one. Add an overloaded function that does the same thing with three double values.
-
Matt Aberham warns against simply trying to "sell yourself" during a phone interview. You agree, but you also believe that selling yourself is one of the things that you to do as a job seeker. What...
-
1. Why did the court rule that the two partners were personally liable for the debt? 2. Could it be argued that the debt actually was incurred once C&E had notice that it had infringed on Dillards...
-
In 1951, DuPont began using the chemical perfluorooctanoic acid to manufacture Teflon. Due to the dangerous nature of the chemical, DuPont was given special instructions by its supplier to dispose of...
-
Tolbert Enterprises Inc. manufactures bathroom fixtures. The stockholders equity accounts of Tolbert Enterprises Inc., with balances on January 1,2012, are as follows: Common Stock , $10 stated value...
-
If Bob faces a 20% chance of losing $20 or an 80% chance of losing nothing. What is the expected loss and variance?
-
In Part III (Appendix 11B) of the audit case, the audit staff of Adams, Barnes & Co. identified specific revenue risks on working paper RA-12 (page 494). However, the Summary of Audit Approach...
-
Windsor Company had the following select transactions. Apr 1.2022 Accepted Goodwin Company's 12-month, 7% note in settlement of a $34,000 account receivable. Loaned $21,000 cash to Thomas Slocombe on...
-
There are two events \(A\) and \(B . P(A)=4\) and \(P(B)=4 . P\left(\begin{array}{ll}A & B\end{array} ight)=\) 24 . (a) Are \(A\) and \(B\) independent events? Explain why or why not. (b) Find...
-
Derive an expression for the law of corresponding states for a gas represented by the following expression: \[p=\frac{\Re T}{v-b}-\frac{a}{T v^{2}}\] \[\left[p_{\mathrm{R}}=\frac{8 T_{\mathrm{R}}}{3...
-
Let \(Z\) have the standard normal distribution. (a) Find \(P\left(\begin{array}{lll}0 & Z & 152\end{array} ight)\). (b) Find \(P\left(\begin{array}{ll}Z & 211\end{array} ight)\). (c) Find...
-
Two fair dice, one red and one green, are rolled. Let the event \(A\) be the sum of the faces showing is an even number. Let the event \(B\) be the sum of the faces showing is divisible by 3 . (a)...
-
Let \(Z\) have the standard normal distribution. (a) Find \(P\left(\begin{array}{lll}0 & Z & 65\end{array} ight)\). (b) Find \(P\left(\begin{array}{ll}Z & 54\end{array} ight)\). (c) Find...
-
Using the Case study Leaked Movie Trailer and a Confidentiality Agreement, write a paper addressing the questions in the Case.
-
Chao, Louis, and Mari, unrelated individuals, own all of the shares of Cerise Corporation. All three shareholders have been active in the management of Cerise since its inception. In the current...
-
The Journal of Accountancy has published a series of articles that address different aspects of disaster recovery and business continuity planning: 1. Gerber, J. A., and Feldman, E. R. 2002. Is Your...
-
You are an audit supervisor assigned to a new client, Go-Go Corporation, which is listed on the New York Stock Exchange. You visited Go-Gos corporate headquarters to become acquainted with key...
-
Lancaster Company makes electrical parts for contractors and home improvement retail stores. After their annual audit, Lancasters auditors commented on the following items regarding internal controls...
-
What encoding scheme is extensive to represent all the characters of all the languages in the world?
-
What is hardware?
-
What is pseudocode?
Study smarter with the SolutionInn App