; Fieldtest mut-local #3 — evaluate the polynomial ; p(x) = 2 x^3 - 3 x^2 + 5 x - 7 ; at x = 2.5 by Horner's method, using a Float mut-var as the running ; accumulator and unrolling the four Horner steps as straight-line ; assigns. ; ; Why this fits mut-local's scope: the accumulator is a Float, the ; updates are straight-line (no iteration), and the mut form removes ; the four nested let-rebinds an LLM-author would otherwise write ; ("p1 = ..., p2 = p1*x + ..., p3 = p2*x + ...") — each rebind needing ; a fresh name. Reusing one name for the running accumulator is the ; natural shape, and mut supplies it. ; ; Hand-check (Horner): start with leading coeff 2.0, then for each ; lower coefficient do acc = acc * x + c: ; 2.0 * 2.5 + (-3) = 5.0 - 3 = 2.0 ; 2.0 * 2.5 + 5 = 5.0 + 5 = 10.0 ; 10.0 * 2.5 + (-7) = 25.0 - 7 = 18.0 ; Expected stdout: 18 (Float 18.0 via %g; print drops the trailing ; ".0" the same way it does for the Float fixture mut_sum_floats.ail.) (module mut-local_3_horner (fn main (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (app print (mut (var acc (con Float) 2.0) (assign acc (app - (app * acc 2.5) 3.0)) (assign acc (app + (app * acc 2.5) 5.0)) (assign acc (app - (app * acc 2.5) 7.0)) acc)))))