Write a scheme function named double-list-elements that takes list as argument a
ID: 3700236 • Letter: W
Question
Write a scheme function named double-list-elements that takes list as argument and returns a list that has a list with all elements doubled value. Write a scheme function double-list-elements-one that uses map function that takes the function and list as two inputs and produces the same output as the previous function Write your own version of map function do not use the predefined one.
Sample runs: (double-list-elements ‘(1 2 3)) should return (2 4 6)
(double-list-elements-one ‘(4 5)) should return (8 10)
Explanation / Answer
#Define the function double-list-element
def double-list-element ( a, b, c):
x=2*a;
y=2*b;
z=2*c;
mylist=[x,y,z];
return [mylist];
# Define the function double-list-elements-one
map(x):
return [2*x];
def double-list-element-one(map,a,b):
for i in 2
c=map(a);
d=map(b);
Newlist=[c,d];
print Newlist;
# Calling functions
arr=[1,2,3];
call_list=double-list-element(arr);
print call_list;
arr1=[4,5];
double-list-element-one(map,arr1);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.