Polynomial long division: Difference between revisions

Content added Content deleted
(→‎{{header|zkl}}: the rest of the bug fix)
Line 1,947: Line 1,947:
str:=[0..].zipWith('wrap(n,a){ if(a) "+ %sx^%s ".fmt(a,n) else "" },terms)
str:=[0..].zipWith('wrap(n,a){ if(a) "+ %sx^%s ".fmt(a,n) else "" },terms)
.sink(String).walk()
.sink(String).walk()
.replace(" 1x"," x").replace("x^0 "," ").replace("x^1 ","x ")
.replace("x^0 "," ").replace(" 1x"," x").replace("x^1 ","x ")
.replace("+ -", "- ");
.replace("+ -", "- ");
if(not str) return(" "); // all zeros
if(not str) return(" "); // all zeros