Hello! I am trying to learn metaprogramming in Julia, and the first problem I’ve had is the following. When I try to define an arbitrary Wilkinson-type polynomial (for instance,
p_5(x) = (x-1) * (x-2) * (x-3) * (x-4) * (x-5) is the polynomial of degree 5), I’ve written this function:
function wp(n::Int) ex = :(x-$n) for i=n-1:-1:1 ex = :($ex*(x-$i)) end return ex end
and it gives an expression which seems correct. However, I don’t know how to evaluate it for some x, say x=1.3. Could you help me? Thank you.