RosettaCodeData/Task/Exponentiation-operator/Slate/exponentiation-operator-2.slate

9 lines
291 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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
].