diff --git a/pez.c b/pez.c index bd9f882..b43d920 100644 --- a/pez.c +++ b/pez.c @@ -1755,6 +1755,19 @@ prim P_log(pez_instance *p) Mathfunc(log); } +prim P_ipow(pez_instance *p) +{ + pez_stackitem i, n; + Sl(2); + + // A somewhat naive implementation: + n = S1; + for(i = 0; i < S0; i++) + S1 *= n; + + Pop; +} + prim P_pow(pez_instance *p) { /* X ^ Y */ Sl(2 * Realsize); @@ -3807,7 +3820,8 @@ static struct primfcn primt[] = { {"0COS", P_cos}, {"0EXP", P_exp}, {"0LOG", P_log}, - {"0POW", P_pow}, + {"0^", P_ipow}, + {"0F^", P_pow}, {"0SIN", P_sin}, {"0SQRT", P_sqrt}, {"0TAN", P_tan}, diff --git a/regress.pez b/regress.pez index a92581e..13567c3 100755 --- a/regress.pez +++ b/regress.pez @@ -679,10 +679,10 @@ variable k 1.0 e f/ log -1.0 fok? "POW" tests: - 2.0 4.0 pow 16.0 fok? - 2.0 -1.0 pow 0.5 fok? - 8.0 1.0 3.0 f/ pow 2.0 fok? - e pi log pow pi fok? + 2.0 4.0 f^ 16.0 fok? + 2.0 -1.0 f^ 0.5 fok? + 8.0 1.0 3.0 f/ f^ 2.0 fok? + e pi log f^ pi fok? "SIN" tests: 0.0 sin 0.0 fok?