<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi<div class=""><br class=""></div><div class="">THIS IS MY CODE:</div><div class=""><br class=""></div><div class=""><div class="">evalpoly = do <span class="Apple-tab-span" style="white-space:pre"> </span>putStr "What is the degree of polynomial: "</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>degree <- getLine</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>coeffs <- (funcOfCoeff ((read degree::Int)+1) [] )</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr "What value do you want to evaluate at: "</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>value <- getLine</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr "the value of "</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr (printChar coeffs)<span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr (" evaluated at "++ value ++" is ")<span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStrLn (show (getResult (coeffs) (read value :: Float) ))</div><div class=""><br class=""></div><div class="">printChar coeffs =parser([x | x <-reverse (zip coeffs (iterate (+1) 0)), fst x /= 0])<span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><br class=""></div><div class="">parser []=""</div><div class="">parser (a:as)=show(fst a) ++ "x^" ++show(snd a) ++ " " ++(parser as) —PROBLEM IS HERE!!!</div><div class=""><br class=""></div><div class="">---function loop to get coefficient--</div><div class=""><br class=""></div><div class="">funcOfCoeff 0 coeffs = do <span class="Apple-tab-span" style="white-space:pre"> </span>--to check the degree of 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>return coeffs<span class="Apple-tab-span" style="white-space:pre"> </span>--return list of coefficient</div><div class=""><br class=""></div><div class="">funcOfCoeff degree coeffs = do <span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr ("What is the x^" ++ show(degree-1))<span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr " coefficient: "</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>coeff <- getLine</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>loop <- funcOfCoeff (degree-1) ((read coeff :: Float) : coeffs)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>return loop</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">getResult (coeffs) x = sum(map(\(a,b) -> a*x^b).zip coeffs.iterate (+1)$0) --evaluate polynomial with value</div></div><div class=""><br class=""></div><div class="">HERE IS MY OUTPUT:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">*Main> evalpoly</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">What is the degree of polynomial: 2</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">What is the x^2 coefficient: 3</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">What is the x^1 coefficient: 2</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">What is the x^0 coefficient: 1</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">What value do you want to evaluate at: 7</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">the value of 3.0x^2 2.0x^1 1.0x^0 evaluated at 7 is 162.0</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">in output, on the very bottom part, there should be + or - sign there like this: 3.0x^2 + 2.0x^1 - 1.0x^0 </div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">what should I do? I have no idea now…..</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">thanks</div><div class=""><br class=""></div></body></html>