Data update

This commit is contained in:
Ingy döt Net 2023-10-02 18:11:16 -07:00
parent 796d366b97
commit 35bcdeebf8
504 changed files with 7045 additions and 610 deletions

View file

@ -0,0 +1,13 @@
func mypow n exp .
r = 1
if exp < 0
exp = -exp
n = 1 / n
.
for i to exp
r *= n
.
return r
.
print mypow pi 2
print mypow 2 -2

View file

@ -1,12 +1,11 @@
subset Natural of Int where { $^n >= 0 }
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 pow (0, 0) { fail '0**0 is undefined' }
multi pow ($base, Natural $exp) { [*] $base xx $exp }
multi pow ($base, Int $exp) { 1 / pow $base, -$exp }
sub infix:<***> ($a, $b) { pow $a, $b }
multi infix:<**> (Real $a, Int $b) { pow $a, $b }
# Testing
say pow .75, -5;
say .75 *** -5;
say .75 ** -5;