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
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
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 the data for IBM options in Problem 3. Suppose a new American-style put option on IBM is issued with a strike price of $155 and an expiration date of November 1st. a. What is the maximum...
-
Eric, your friend, received his Form W-2 from his employer (below) and has asked for your help. Erics 2018 salary was $145,000 and he does not understand why the amounts in Boxes 1, 3 and 5 are not...
-
If the excitation of a linear system is a Gaussian process, the response will be a. a different random process b. a Gaussian process c. an ergodic process
-
Juice Extracts Company produces a line of fruit extracts for home use in making wine, jams and jellies, pies, and meat sauces. Fruits enter the production process in pounds, and the product emerges...
-
The sell-by dating on dairy products depends on the solution of a differential equation. The rate of growth of bacteria in such products increases with time. If y is the number of bacteria (in...
-
The director of RCM inc. plans to launch a new product. The initial investment in equipment and other fittings is $800,000. It's been a while since management thinking of launching this new product....
-
Pick a specific business - as a potential investor in that business, what areas of that business's cash flow statement would you be interested in and why?
-
This question illustrates two similar ways to forecast future stock prices. You will use SimpleForecast.xlsx for this exercise. It gives the historical monthly closing prices for a five-year period...
-
Sales Cost of goods sold. Gross margin Selling and administrative expenses Net operating income Nonoperating items: Gain on sale of equipment Income before taxes Income taxes Net income Assets Cash...
-
BBY GD STT Russell 1000 1-Year T-Bill Date Price Shrout Dividend Price Shrout Dividend Price Shrout Dividend Total Return Index Annual YTM (%) 12/31/15 30.45 342720 137.36 316128 66.36 403486...
-
solve the SERVER SIDE Questions ONLY : Directions: Now that you know what the differences are and can design the code for various operating platforms ( as seen above ), you will use your experience...
-
Evaluating cash flows with the NPV method The net present value (NPV) rule is considered one of the most common and preferred criteria that generally lead to good investment decisions. Consider this...
-
Complete the equations for the following equilibria and calculate Keq where the Keq expression includes [HO]. Be sure to enter Keq in proper scientific notation. (a) ammonia (acting as a base) reacts...
-
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...
-
Consider the ammonia process in which \(\mathrm{N}_{2}\) and \(\mathrm{H}_{2}\) (with impurities \(\mathrm{Ar}\) and \(\mathrm{CH}_{4}\) ) are converted to \(\mathrm{NH}_{3}\) at high pressure...
-
Use a process simulator to model a two-stage compression system with an intercooler. The feed stream consists of \(95 \mathrm{~mol} \%\) hydrogen and \(5 \mathrm{~mol} \%\) methane at \(100^{\circ}...
-
The feed (equimolar A and B) to a reactor is heated from \(100^{\circ} \mathrm{F}\) to \(500^{\circ} \mathrm{F}\) in a \(1-2\) parallel-counterflow heat exchanger with a mean overall heat-transfer...
Study smarter with the SolutionInn App