clc
clear

function y = myHorner(p, x0)
    c = coeff(p);
    n = degree(p) + 1;
    y = c(n);
    for i = n-1:-1:1
        y = y*x0 + c(i);
    end
endfunction

p = poly([1 4 -2 3], "x", "coeff");

mprintf("The answer is %d\n", myHorner(p, -1));
mprintf("The answer is %d\n", myHorner(p, 3));
mprintf("The answer is %d\n", myHorner(p, 0));
