Question: ;; ;; Write a RECURSIVE function `(eval-polynomial coefficients x)` ;; that accepts a list (a0, a1, ..., a_n) of n+1 coefficients, ;; and returns result
;; ;; Write a RECURSIVE function `(eval-polynomial coefficients x)` ;; that accepts a list (a0, a1, ..., a_n) of n+1 coefficients, ;; and returns result of evaluating the order-n polynomial ;; p(x) = a0 + a1 x + a2 x^2 + ... + a_n x^n. ;; If the list of coefficients is empty, ;; then p(x) should return zero. ;; ;;;;;;;;; (define (eval-polynomial coefficients x) 0 ) ;;;;;;;;;;;;; ;; Tests (define (println s) (begin (display s) (newline))) (println (eval-polynomial `() 5) ; Expext 0 ) (println (eval-polynomial `(10 3 -4 2) 5) ; Expect 175 ) (println (eval-polynomial `(10) 3) ; Expect 10 )
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
