<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=""><div class="">Hi</div><div class=""><br class=""></div><div class="">i have a problem in my code!</div><div class=""><br class=""></div><div class="">here is my code:</div><div class=""><br class=""></div><div class=""><div class="">-- Baic I/O and Loop (50 Points)</div><div class=""><br class=""></div><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<span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr "The value of the polynomial is: "</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr (show (polyEvaluate (coeffs) (read value :: Float) ))</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>putStr "\n"</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 :: Int) : 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=""><span class="Apple-tab-span" style="white-space:pre"> </span></div><div class="">polyEvaluate (coeffs) x = do</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>powers <- zip coeffs (iterate (+1) 0)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>result <- map (\(a,b)-> a+b) powers<span class="Apple-tab-span" style="white-space:pre"> </span>—PROBLEM IS HERE!!!!</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>return result</div><div class=""><br class=""></div><div class=""><div class="">here is error message:</div><div class=""><br class=""></div><div class=""><img apple-inline="yes" id="A3F35BA9-3D68-48FE-94B1-57D88A3F63B9" height="152" width="375" apple-width="yes" apple-height="yes" src="cid:C6FEB6E1-8BDA-4837-AF14-F06EBE296C84" class=""></div><div class=""><br class=""></div><div class="">in very bottom function (polyEvaluate), why is not working “result <- map (\(a,b) -> a+b) powers” ???</div><div class=""><br class=""></div><div class="">in Prelude, it is working</div><div class=""><br class=""></div><div class=""><img apple-inline="yes" id="B91FAD4F-4500-4FCC-B567-8F84B55741CC" height="46" width="285" apple-width="yes" apple-height="yes" src="cid:B2077ACB-2F62-4D6F-9ECA-92B1F7B0CB36" class=""></div><div class=""><br class=""></div><div class="">Thanks!</div></div></div></body></html>