Polynomial derivative: Difference between revisions

→‎{{header|Wren}}: Although appeared to work, wasn't quite right before.
(→‎{{header|Wren}}: Now prints polynomials in 'normal' notation too.)
(→‎{{header|Wren}}: Although appeared to work, wasn't quite right before.)
Line 182:
for (i in 0...p.count) {
if (p[i] == 0) continue
var c = p[i].toString
if (i > 0 && p[i].abs == 1) c = (p[i] == 1) ? "" : "-"
var x = (i > 0) ? "x" : ""
terms.add("%(p[i]c)%(x)%(superscript.call(i))")
}
return terms[-1..0].join("+").replace("1x", "x").replace("+-", "-")
}
 
9,488

edits