Data update
This commit is contained in:
parent
796d366b97
commit
35bcdeebf8
504 changed files with 7045 additions and 610 deletions
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue