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 a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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