RosettaCodeData/Task/Exponentiation-operator/Slate/exponentiation-operator-2.slate
2023-07-01 13:44:08 -04:00

8 lines
291 B
Text

x@(Float traits) raisedTo: y@(Float traits)
"Implements floating-point exponentiation in terms of the natural logarithm
and exponential primitives - this is generally faster than the naive method."
[
y isZero ifTrue: [^ x unit].
x isZero \/ [y isUnit] ifTrue: [^ x].
(x ln * y) exp
].