Recursive double function

Assignment Help Programming Languages
Reference no: EM13312187

Part 1: The Double Functions

Write the following three functions.
double-recursive (y)
double-iterative (y)
double-mapcar (y)

each of these returns the list consisting of each element of list y in a list has been replaced by two copies of the elements. For example,

(double-recursive '(1 2 3))

returns

(1 1 2 2 3 3)

If y is not a list, then nil is returned.

These double functions work only at the top-level; For example,

(double-recursive '(1 (2 3) 4))

returns

(1 1 (2 3) (2 3) 4 4)

Note how the top-level elements are duplicated, but the elements of nested lists are not. double-recursive is to be written recursively, double-iterative is to be written iteratively using either ‘go' or ‘do', and double-mapcar is to be written using ‘mapcar'. Hint: for dou- ble-mapcar,use the "apply-append trick" (see text).

Part 2: The Recursive Double Function

Write the function

rdouble (y)

On non-nested lists, it behaveslikethe double functions above.Onnested lists, however, it returns a list of duplicates of the inner elements. Forexample,

(rdouble '(1 (2 3) 4))

returns

(1 1 (2 2 3 3) 4 4)

rdouble is to be written recursively (no iteration is allowed). Hint: use car-cdr recursion.

Part 3: The my-mapcar Function

Write the function

my-mapcar (fun l1 l2)

it behavesexactly as mapcar using fun with argument lists l1 and l2. Assume that my-map- car is invokedonly with the twoargument lists and that fun can be evaluated on twoargu-ments. Write my-mapcar recursively.Use no iteration or mapping functions


Attachment:- PL_Question.zip

Reference no: EM13312187

Questions Cloud

Find who has more momentum : A 100 kg running back carries the ball forward with a speed of 9 m/s. He is hit head on in the air at the goal line by a 130 kg defensive back running in the opposite direction at 7 m/s
Determine what is the expected cycle service level : Demand for a particular product is normally distributed with a mean of 100 units and a standard deviation of 20 per period. if there are 120 units in inventory at the beginning of this period
Find the magnitude of the average force acting on the ball : An object of mass 0.77 kg is initially at rest. When a force acts on it for 2.9 ms it acquires a speed of 16.2 m/s. Find the magnitude of the average force acting on the ball
Determine the specific speed ad brake horsepower : The 35-in pump of fig. 11.7b is used to pump 24000 GPM of water (68ft) at 710 rpm from a large tank whose surface is at atmospheric presure. the head loss from tank to the pump inlet is 3ft.
Recursive double function : each of these returns the list consisting of each element of list y in a list has been replaced by two copies of the elements and
How much calcium bicarbonate will need to be added : How much calcium bicarbonate (kg/day) will need to be added per day in water with alkalinity of 30 mg/L CaCO3 (assume for simplicity only bicarbonate alkalinity is present) if 794 kg of (Al2(SO4)3 x 18H20 is added per week
What is the car doing at that instant : A car is moving in a circular path. At a certain instant, it has zero tangential acceleration and a non-zero centripetal acceleration
Explain how to estimate the flow rate of water : the pressure drop over 15 m of 2-cm diameter galvanized iron pipe is measured to be 60 Pa. If the pipe is horizontal, estimate the flow rate of water. use for water v=10^-6 m^2/s and density of water = 1000kg/m^3
Business research in order to forecast and predict purposes : Multiple regression analysis is widely used in business research in order to forecast and predict purposes. It is also used to determine what independent variables have an influence on dependent variables, such as sales.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write application to inputs ten numbers from user

Write the application to inputs ten numbers from user, each number can be between 10 and 100, inclusive. As each number is read in determine if it is number already entered.

  Write script to declare and sets variable equal to balance

Write a script that declares and sets a variable that's equal to the total outstanding balance due. If that balance is greater than $10,000.00, the script should return a result set consisting of VendorName.

  Create new method for random turning

Create new method named randomTurn (this method has no parameters and returns nothing). Select the code that does the random turning.

  Design application that reads arbitary number of integers

Design and implement an application that reads an arbitary number of integers that are in the range of 0 to 50 inclusive and counts how many occurences of each are entered.

  Write a full program to convert seconds into hours

Write a full program (starting from #include) that takes as input the number of seconds after midnight and displays the time in hours.

  Create program to calculate and display number of miles

Create a program to calculate and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speed limit and the drivers speed.

  Write pseudocode

Write pseudocode that represents the abstract functions of the enqueue and dequeue operations. Define and explain any supplementary information needed by your pseudocode.

  Write program for department of motor vehicles

Department of motor vehicles has finally decided to computerize its list of licensed drivers. Program you write must make use of existing file call Licenses with records of given form. Name, License Number

  Program to display contents of file in separate line

Display the contents of the file GRADES created in Problem 1. Each student's record should appear on a separate line and include the total score (the sum of the three tests) for that student.

  Perform a paired t-test to verify your claim

Which type of t-test is most appropriate to investigate your co-investigator's claim? Why is it most appropriate t- test? Please explain your answer in 1-2 lines.

  Program which calculate and displays fifteen percent tip

Write a program which calculate and displays a 15 percent tip when the price of a meal is input by the user. (Hint: the tip is computed by multiplying the price of the meal by 0.15.).

  Create a function that takes a one dimentional array

Create a function that takes a one dimentional array us a argument the function should return only these members from the array which are divisible by 4.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd