aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator2.mo
blob: cf86779de7d096c1ef26622f8e11119534f16983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function PolynomialEvaluator2
    input Real a[:];
    input Real x;
    output Real y;
protected
    Real xpower;
algorithm
    y := 0;
    xpower := 1;
    for i in 1:size(a, 1) loop
        y := y + a[i]*xpower;
        xpower := xpower*x;
    end for;
end PolynomialEvaluator2;