RosettaCodeData/Task/Exponentiation-operator/Raku/exponentiation-operator.raku
2023-10-02 18:11:16 -07:00

11 lines
294 B
Raku

proto pow (Real, Int --> Real) {*}
multi pow (0, 0) { fail '0**0 is undefined' }
multi pow ($base, UInt $exp) { [*] $base xx $exp }
multi pow ($base, $exp) { 1 / samewith $base, -$exp }
multi infix:<**> (Real $a, Int $b) { pow $a, $b }
# Testing
say pow .75, -5;
say .75 ** -5;