Question
Can you help me with this problem on Racket? Last time, we wrote a function, eval-quadratic, to calculate the y -value of a quadratic function
Can you help me with this problem on Racket?
Last time, we wrote a function, eval-quadratic, to calculate the y-value of a quadratic function at a given x-value. It took four parameters; the first three were the three coefficients of a quadratic equation.
This was a bit unwieldy; it would be better to bundle together these three values into a single data structure. So, let's do that with the following struct definition:
(define-struct Quadratic ([a : Real] [b : Real] [c : Real]))
(: to-string : Quadratic -> String) Return a string of the form "ax^2+bx+c". Use the built-in functions string-append and number->string. It is acceptable if you return a string with coefficients of 0 or 1, but it would be a very nice touch to omit terms with coefficients of zero entirely, and, for terms with coefficients of 1, skip the coefficient. For negative coefficients, you can represent them with a negative number, even if that would result in a negative coefficient after a plus sign in the formula, but it would be a nice touch to use a positive coefficient and replace the plus sign with a minus sign instead.
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