Answered step by step
Verified Expert Solution
Question
1 Approved Answer
;; ;; 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started