Question

This problem need to use DrRacket software. Racket Language. You must write each of the following...

This problem need to use DrRacket software. Racket Language.

You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects.

Write a function (join-together L1 L2) that takes a sorted list (ascending) of integers L1 and a sorted list of elements L2 and returns a sorted list containing all elements of both L1 and L2. See the following examples for clarification.

(join-together '(3 12 18) '(-12 15 22)) ---> (-12 3 12 15 18 22)
(join-together '() '(-12 15 22)) ---> (-12 15 18)
(join-together '(3 12 18) '()) ---> (3 12 18)
(join-together '(3 4 5) '(100 200 300 400 500 600)) ---> (3 4 5 100 200 300 400 500 600)

Homework Answers

Answer #1

(define (join-together x y)
(cond
[(null? y) x]
[(null? x) y]
[(> (car y) (car x));
(cons (car x) (join-together (cdr x) y))]
;cons head x to (recurse)
[(cons (car y) (join-together x (cdr y)))]))
;cons head y to (recurse)

(print (join-together '(3 12 18) '(-12 15 22)))
(print (join-together '() '(-12 15 18)))
(print (join-together '(3 12 18) '()))
(print (join-together '(3 4 5) '(100 200 300 400 500 600)))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
You must write each of the following scheme functions. You must use only basic scheme functions...
You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects. Write a function (running-sum L) that takes a list of numbers L and generates a list of the runnining sums. See the following examples for clarification. (running-sum '(1 2 3)) ---> (1 3 6) (running-sum '()) ---> () (running-sum '(3 0 -2 3)) ---> (3...
Given the following information, use Excel’s Regression tool and scatter plot tool to: (No need to...
Given the following information, use Excel’s Regression tool and scatter plot tool to: (No need to show the regression and scatter plot just answer the questions.) (c) What is the 95% prediction interval for the true overhead when the number of units produced is 1,000? Month Units produced Manuf. Overhead 1 500 131,000 2 600 135,000 3 400 104,000 4 300 76,000 5 800 186,000 6 900 190,100 7 600 150,000 8 400 98,000 9 300 78,000 10 200 60,000...
Problem 2. Consider the following series of cash flows: Cumulative Month Amount 0 1 2 3...
Problem 2. Consider the following series of cash flows: Cumulative Month Amount 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 CF (1,000s of $) $400.00 -700 1200 600 300 -1000 -1200 -400 -300 -1000 1200 400 300 1000 -1200 -400 -300 1000 1200 400 300 -1000 What is the NPV if the MARR yields 15%? Compute your solution by two (2) methods as follows:   Example. Compute the...
You are to write a C++ program to produce an inventory report for a local company....
You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. The following shows which columns the input will be in: item name             item number         quantity                  price                      safe stock 20 chars                 5 char                     3 char                      6 chars                 3 chars Output will be as follows: item number         item name    quantity   price     price*quantity   %ofStock    flag You will put a symbol in the...
You are to write a program to produce an inventory report for a local company. Your...
You are to write a program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. The following shows which columns the input will be in: item name item number quantity price safe stock 20 chars 5 char 3 char 6 chars 3 chars Output will be as follows: item number item name quantity   price   price*quantity   %ofStock flag You will put a symbol in the flag...
You can complete this assignment individually or as a group of two people. In this assignment...
You can complete this assignment individually or as a group of two people. In this assignment you will create a ​​Sorted Singly-Linked List​ that performs basic list operations using C++. This linked list should not allow duplicate elements. Elements of the list should be of type ‘ItemType’. ‘ItemType’ class should have a private integer variable with the name ‘value’. Elements in the linked list should be sorted in the ascending order according to this ‘value’ variable. You should create a...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing text files, writing functions, and program planning and development. You will read a data file and store all of the input data in a two dimensional array. You will perform calculations on the data and store the results in the 2 dimensional array. You will sort the array and print the results in a report. Instructions You will read in the same input file...
Using the data in the table below, answer the following questions. (Hint: draw a graph when...
Using the data in the table below, answer the following questions. (Hint: draw a graph when possible) Interest Rate% Money Demand (billions of dollars) 19 100 18 120 17 140 16 160 15 200 14 260 13 320 12 400 11 500 Assume that the money supply is equal to 160 (do not use % signs in your answers) Part 1: What is the equilibrium rate of interest? Part 2: Assume that the Bank of Canada buys bonds and increases...
For each of the following questions, use Microsoft Excel to find the solution. Be sure to...
For each of the following questions, use Microsoft Excel to find the solution. Be sure to describe which functions you used and how you got the answer. Feel free to use whatever approach you want to get the right answer. Here are some functions you might find useful: BINOM.DIST POISSON.DIST HYPGEOM.DIST NORM.DIST Over the next 30 days, the pool has a 15% chance of closing each day. The closings are independent from each other. What is the probability that the...
Part I Carl Redmon completed the following transactions during December: Dec 2   Invested $25,000 to start...
Part I Carl Redmon completed the following transactions during December: Dec 2   Invested $25,000 to start a consulting practice titled Redmon Consulting.         2   Paid $6,000 for a 2-year insurance policy.         3   Paid cash for a computer, $2,400. It is expected to remain in service for five years, and have a $400 salvage value at the end of its useful life.         4   Purchased office furniture on account, $4,500. The furniture should last for five years.         5   Purchased...