Write a Scheme program for each of the following. You can use the linprog server for...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Scheme program for each of the following. You can use the "linprog" server for your implementation - it has Scheme installed in it. a) To reverse a list. You are not allowed to use the built-in function "reverse". Input to the program is a list. Print the final list. For instance, Ist = (5 11 22 3) output: (3 22 11 5) (5 points) b) To insert an element "a" in a sorted list "Ist" (sorted in ascending order), such that the resulting list is still sorted. Input to the program are "a" and "Ist". Print the final list. For instance, 1st (14 7 12 19) and a = 6, output: (1467 12 19) (5 points) c) To check if an item "a" is present in a list "Ist". The program should return "#t" if the item is present and "#f" otherwise. Input to the program are "a" and "Ist". For instance, 1st (6 22 3 7 8) and a = 3 output: #t 1st (6 22 3 7 8) and a = 9 output: #f (5 points) d) Which takes in two lists "Ist 1" and "Ist2", both of which are individually sorted (in ascending order), and returns a list containing the elements of both Ist1 and 1st2 in sorted order. Print the final list. Input to the program are "Ist 1" and "Ist2". For instance, 1st 1 (1357) and 1st2 = (2468) output: (12345678) (5 points) Write a Scheme program for each of the following. You can use the "linprog" server for your implementation - it has Scheme installed in it. a) To reverse a list. You are not allowed to use the built-in function "reverse". Input to the program is a list. Print the final list. For instance, Ist = (5 11 22 3) output: (3 22 11 5) (5 points) b) To insert an element "a" in a sorted list "Ist" (sorted in ascending order), such that the resulting list is still sorted. Input to the program are "a" and "Ist". Print the final list. For instance, 1st (14 7 12 19) and a = 6, output: (1467 12 19) (5 points) c) To check if an item "a" is present in a list "Ist". The program should return "#t" if the item is present and "#f" otherwise. Input to the program are "a" and "Ist". For instance, 1st (6 22 3 7 8) and a = 3 output: #t 1st (6 22 3 7 8) and a = 9 output: #f (5 points) d) Which takes in two lists "Ist 1" and "Ist2", both of which are individually sorted (in ascending order), and returns a list containing the elements of both Ist1 and 1st2 in sorted order. Print the final list. Input to the program are "Ist 1" and "Ist2". For instance, 1st 1 (1357) and 1st2 = (2468) output: (12345678) (5 points)
Expert Answer:
Related Book For
Business Communication Essentials a skill based approach
ISBN: 978-0132971324
6th edition
Authors: Courtland L. Bovee, John V. Thill
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...
-
1/ You just started working and you planned to save $5,000 every year in your retirement account. How much money will you have in your retirement account once you retire in 40 years? Your retirement...
-
Consider an American put option on XAL stock with a strike price of $55 and one year to expiration. Assume XAL pays no dividends, XAL is currently trading for $10 per share, and the one-year interest...
-
Fill in the blank with an appropriate word, phrase, or symbol(s). The formula used to determine the equation for the axis of symmetry of a parabola is _________.
-
Which of the following is an activity not usually associated with forensic accounting and fraud examination consulting and litigation support? 1. A. Assessing fraud risk associated with internal...
-
The pretax financial income of Truttman Company differs from its taxable income throughout each of 4 years, as shown on page 1058. Pretax financial income for each year includes a non-deductible...
-
The local theater company is choosing its next play. The company's members recently held a vote to decide which of three choices - Elektra, Tartuffe, and Hamlet - the company will perform. The...
-
A particle of mass mo and charge e oscillates along the x-axis in a 1-D Harmonic potential with an angular frequency w. It an electric field e is applied along the x-axis, evaluate the first and...
-
Evaluate the appropriate level of safety inventory for a supply chain.
-
Identify factors that influence the required level of safety inventory.
-
As a supermarket operator, would you hold more safety inventory for a newly introduced detergent or for an existing detergent? Why?
-
How should safety inventory be managed in a multiechelon supply chain?
-
Identify the factors that affect the correct level of safety inventory. What impact does each have on determining the correct level of safety inventory?
-
The moment of inertia of the rotor of the medical centrifuge is I = 0.2 kg-m2 . The rotor starts from rest and the motor exerts a constant torque of 0.8 N-m on it. (a) How much work has the motor...
-
Consider the sections of two circuits illustrated above. Select True or False for all statements.After connecting a and b to a battery, the voltage across R1 always equals the voltage across R2.Rcd...
-
What is the AIDA model, and what are its limitations?
-
Define ethics and explain what ethical communication encompasses.
-
Read the following document and (a) Analyze the strengths and weaknesses of each sentence and (b) Revise the message so that it follows this chapter's guidelines. I am responding to your letter of...
-
The expected effect on market efficiency of opening a securities market to trading by foreigners would be to: A. Decrease market efficiency. B. Leave market efficiency unchanged. C. Increase market...
-
Suppose that a speculative-grade bond issuer announces, just before bond markets open, that it will default on an upcoming interest payment. In the announcement, the issuer confirms various reports...
-
1. An analyst estimates that a securitys intrinsic value is lower than its market value. The security appears to be: A. Undervalued. B. Fairly valued. C. Overvalued. 2. A market in which assets...
Study smarter with the SolutionInn App