RosettaCodeData/Task/Exponentiation-operator/Lingo/exponentiation-operator.lingo

15 lines
299 B
Text
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
-- As for built-in power() function:
-- base can be either integer or float; returns float.
on pow (base, exp)
if exp=0 then return 1.0
else if exp<0 then
exp = -exp
base = 1.0/base
end if
res = float(base)
repeat with i = 2 to exp
res = res*base
end repeat
return res
end