Question: Functional Programming using scheme. Please answer using Dr Racket. Create a scheme function that takes two lists and returns a single list. For example, add
Functional Programming using scheme. Please answer using Dr Racket.
Create a scheme function that takes two lists and returns a single list. For example, add the two input lists together to create one output list. Below is the test cases that should work when you type them in.
(display (vecadd '() '())) (newline) ; () (display (vecadd '(1) '(2))) (newline) ; (3) (display (vecadd '(1 2 3) '(4 5 6))) (newline) ; (5 7 9) (display (vecadd '(1 . 3) '(4 . 6))) (newline) ; (5 . 9)
Create a second function "vecfn" that allows one to pass the function to perform on the input lists as the first argument. Below are the test cases that should work when you type them in.
(display (vecfn - '(1 2 3) '(4 5 6))) (newline) (display (vecfn + '(4) (list (sqrt -1)))) (newline) (display (vecfn / '(1 2 3) '(1 4 5))) (newline)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
