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
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.
|