RosettaCodeData/Task/Exponentiation-operator/Quackery/exponentiation-operator.quackery
2023-07-01 13:44:08 -04:00

34 lines
789 B
Text

[ $ "bigrat.qky" loadfile ] now!
forward is ** ( n n --> n )
[ dup 1 < iff
[ 2drop 1 ] done
dup 1 & iff
[ 1 - dip dup ** * ]
else
[ 1 >> dip [ dup * ]
** ] ] resolves ** ( n n --> n )
forward is (v**) ( n/d n --> n/d )
[ dup 0 = iff
[ drop 2drop 1 n->v ]
done
dup 1 & iff
[ 1 - dip 2dup (v**)
v* ]
else
[ 1 >>
dip [ 2dup v* ]
(v**) ] ] resolves (v**) ( n/d n --> n/d )
[ dup 0 < iff
[ abs (v**) 1/v ]
else (v**) ] is v** ( n/d n --> n/d )
say "The 10th power of 2 is: "
2 10 ** echo cr cr
say "The -10th power of 2.5 is: "
$ "2.5" $->v drop -10 v** 20 point$ echo$