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...
Chirico Manufacturing Company uses job costing system. The following job cost records were provided for January,...
Chirico Manufacturing Company uses job costing system. The following job cost records were provided for January, the company’s first month of operations: Job 1 Job 2 Job 3 Job 4 Job 5 Direct materials used $100 $400 $300 $200 $400 Direct labor cost 300 600 200 500 100 Allocated overhead 300 600 200 500 100 Total $700 $1,600 $700 $1,200 $600 Date started 01/02 01/10 01/20 01/25 01/22 Date completed 01/18 01/20 01/30 02/02 02/10 Date delivered to customer 01/20...
Machine Problem 3 - Linked List C++ For this assignment you will write a program that...
Machine Problem 3 - Linked List C++ For this assignment you will write a program that inserts 20 random integers from 0 to 100 in order in a linked list object. The program will create another linked list, but with 15 random integers from 0 – 100 in order. The program then will merge those two ordered linked list into a single ordered list. The function merge should receive references to each of the list objects to be merged and...
Create an MS word document that lists each Quantitative variable in the Class Survey Data, provide...
Create an MS word document that lists each Quantitative variable in the Class Survey Data, provide a point estimate of the mean (the sample mean) and a 95% Confidence Interval for the sample mean for each variable. Watch TV Credits Sleep Work (hrs) Songs downloaded FB Friends 1 15 7 50 50 34 0 14 8 30 2000 0 1 16 6 0 500 300 4 21 4.5 0 0 635 0 16 8 3 290 0 0 19 6.5...
Assume data coming from a price skimming experiment, where the price of a particular product was...
Assume data coming from a price skimming experiment, where the price of a particular product was reduced in an online platform over 17 consecutive days, in steps of $50 from an initial value of $1,000 to a final value of $200. The price was maintained constant during each day, and was changed at the beginning of the following day. The last column represents the total number of purchases observed during the corresponding day. b) Plot the empirical revenue function, for...
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...
Assume data coming from a price skimming experiment, where the price of a particular product was...
Assume data coming from a price skimming experiment, where the price of a particular product was reduced in an online platform over 17 consecutive days, in steps of $50 from an initial value of $1,000 to a final value of $200. The price was maintained constant during each day, and was changed at the beginning of the following day. The last column represents the total number of purchases observed during the corresponding day. Using the linear demand function, and assuming...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT