Packages now properly work when imported
This commit is contained in:
@@ -71,11 +71,10 @@ endfun
|
||||
|
||||
fun -double !cos -double &in
|
||||
# Get input modulo 2π
|
||||
call !pi &pi
|
||||
call !math:pi &pi
|
||||
multiply $pi 2 &tau
|
||||
pusharg $in
|
||||
pusharg $tau
|
||||
call !mod &in
|
||||
pusharg $in $tau
|
||||
call !math:mod &in
|
||||
|
||||
set &idx 0
|
||||
set &ans 0
|
||||
@@ -97,11 +96,11 @@ fun -double !cos -double &in
|
||||
tostring $2k+1 &2k+1
|
||||
stoi $2k+1 &2k+1
|
||||
pusharg $2k+1
|
||||
call !intexp &exp
|
||||
call !math:intexp &exp
|
||||
|
||||
# Get (2k+1)!
|
||||
pusharg $2k+1
|
||||
call !factorial &fact
|
||||
call !math:factorial &fact
|
||||
|
||||
# Divide
|
||||
divide $exp $fact &tempans
|
||||
@@ -112,7 +111,7 @@ fun -double !cos -double &in
|
||||
pusharg $idx
|
||||
stod "2" &store
|
||||
pusharg $store
|
||||
call !mod &store
|
||||
call !math:mod &store
|
||||
equal $store 0 &store
|
||||
if $store %subtract
|
||||
jump %add
|
||||
@@ -141,26 +140,26 @@ fun -double !cos -double &in
|
||||
endfun
|
||||
|
||||
fun -double !sin -double &in
|
||||
call !pi &halfpi
|
||||
call !math:pi &halfpi
|
||||
divide $halfpi 2 &halfpi
|
||||
subtract $halfpi $in &in
|
||||
pusharg $in
|
||||
call !cos &store
|
||||
call !math:cos &store
|
||||
return $store
|
||||
endfun
|
||||
|
||||
fun -double !tan -double &in
|
||||
pusharg $in
|
||||
call !sin &store
|
||||
call !math:sin &store
|
||||
pusharg $in
|
||||
call !cos &store2
|
||||
call !math:cos &store2
|
||||
divide $store $store2 &store
|
||||
return $store
|
||||
endfun
|
||||
|
||||
fun -double !asin -double &in
|
||||
pusharg $in
|
||||
call !abs &store
|
||||
call !math:abs &store
|
||||
greater $store 1 &store
|
||||
if $store %error
|
||||
|
||||
@@ -170,10 +169,10 @@ fun -double !asin -double &in
|
||||
stod "0" &ans
|
||||
@loop
|
||||
pusharg $ans
|
||||
call !sin &sin
|
||||
call !math:sin &sin
|
||||
subtract $sin $in &sin
|
||||
pusharg $ans
|
||||
call !cos &cos
|
||||
call !math:cos &cos
|
||||
divide $sin $cos &store
|
||||
subtract $ans $store &ans
|
||||
equal $store 0 &store
|
||||
@@ -190,8 +189,8 @@ endfun
|
||||
fun -double !acos -double &in
|
||||
# asin(x) + acos(x) = pi/2
|
||||
pusharg $in
|
||||
call !asin &store
|
||||
call !pi &pi
|
||||
call !math:asin &store
|
||||
call !math:pi &pi
|
||||
divide $pi 2 &pi
|
||||
subtract $pi $store &store
|
||||
return $store
|
||||
@@ -205,18 +204,18 @@ fun -double !atan -double &in
|
||||
@loop
|
||||
|
||||
pusharg $ans
|
||||
call !tan &num
|
||||
call !math:tan &num
|
||||
subtract $num $in &num
|
||||
|
||||
pusharg $ans
|
||||
call !cos &dom
|
||||
call !math:cos &dom
|
||||
multiply $dom $dom &dom
|
||||
|
||||
multiply $num $dom &store
|
||||
subtract $ans $store &ans
|
||||
|
||||
pusharg $store
|
||||
call !abs &store
|
||||
call !math:abs &store
|
||||
lesser $store 0.000000000001 &store
|
||||
if $store %return
|
||||
|
||||
@@ -224,23 +223,23 @@ fun -double !atan -double &in
|
||||
|
||||
@return
|
||||
# Make answer in range [-pi/2, pi/2]
|
||||
call !pi &pi
|
||||
call !math:pi &pi
|
||||
pusharg $ans
|
||||
pusharg $pi
|
||||
call !mod &ans
|
||||
call !math:mod &ans
|
||||
divide $pi 2 &pi
|
||||
greater $ans $pi &store
|
||||
if $store %negans
|
||||
return $ans
|
||||
|
||||
@negans
|
||||
call !pi &pi
|
||||
call !math:pi &pi
|
||||
subtract $ans $pi &ans
|
||||
return $ans
|
||||
endfun
|
||||
|
||||
fun -double !atan2 -double &y -double &x
|
||||
call !pi &pi
|
||||
call !math:pi &pi
|
||||
divide $pi 2 &pi/2
|
||||
|
||||
# catch "mathError" ÷ByZero
|
||||
@@ -259,19 +258,19 @@ fun -double !atan2 -double &y -double &x
|
||||
if $store %quadrant3
|
||||
|
||||
pusharg $ratio
|
||||
call !atan &store
|
||||
call !math:atan &store
|
||||
add $store $pi &store
|
||||
return $store
|
||||
|
||||
@quadrant3
|
||||
pusharg $ratio
|
||||
call !atan &store
|
||||
call !math:atan &store
|
||||
subtract $store $pi &store
|
||||
return $store
|
||||
|
||||
@atan
|
||||
pusharg $ratio
|
||||
call !atan &store
|
||||
call !math:atan &store
|
||||
return $store
|
||||
|
||||
@error
|
||||
@@ -302,7 +301,7 @@ fun -double !random -int &seed
|
||||
stod $store &store
|
||||
pusharg $store
|
||||
pusharg $m
|
||||
call !mod &store
|
||||
call !math:mod &store
|
||||
divide $store 2147483648 &store
|
||||
return $store
|
||||
endfun
|
||||
@@ -358,7 +357,7 @@ fun -double !abs -double &in
|
||||
endfun
|
||||
|
||||
fun -double !exp -double &in
|
||||
call !e &e
|
||||
call !math:e &e
|
||||
|
||||
lesser $in 0 &store
|
||||
if $store %negative
|
||||
@@ -367,15 +366,15 @@ fun -double !exp -double &in
|
||||
pusharg $in
|
||||
stod "1.00" &store
|
||||
pusharg $store
|
||||
call !mod &floorin
|
||||
call !math:mod &floorin
|
||||
subtract $in $floorin &floorin
|
||||
pusharg $floorin
|
||||
call !dtoi &floorin
|
||||
call !math:dtoi &floorin
|
||||
|
||||
# e^(a+x)=e^a*e^x
|
||||
pusharg $e
|
||||
pusharg $floorin
|
||||
call !intexp &e^a
|
||||
call !math:intexp &e^a
|
||||
|
||||
# Find e^($in - $floorin)
|
||||
subtract $in $floorin &x
|
||||
@@ -389,10 +388,10 @@ fun -double !exp -double &in
|
||||
|
||||
pusharg $x
|
||||
pusharg $idx
|
||||
call !intexp &store
|
||||
call !math:intexp &store
|
||||
|
||||
pusharg $idx
|
||||
call !factorial &fact
|
||||
call !math:factorial &fact
|
||||
|
||||
divide $store $fact &store
|
||||
|
||||
@@ -409,7 +408,7 @@ fun -double !exp -double &in
|
||||
# e^-x = 1/e^x
|
||||
multiply $in -1 &in
|
||||
pusharg $in
|
||||
call !exp &store
|
||||
call !math:exp &store
|
||||
divide 1 $store &store
|
||||
return $store
|
||||
|
||||
@@ -432,13 +431,13 @@ fun -double !ln -double &in
|
||||
|
||||
@loop
|
||||
pusharg $ans
|
||||
call !exp &e^x
|
||||
call !math:exp &e^x
|
||||
subtract $e^x $in &store
|
||||
divide $store $e^x &store
|
||||
subtract $ans $store &ans
|
||||
|
||||
pusharg $store
|
||||
call !abs &store
|
||||
call !math:abs &store
|
||||
lesser $store 0.000000000001 &store
|
||||
if $store %return
|
||||
|
||||
@@ -505,7 +504,7 @@ fun -double !rpn -list &rpn
|
||||
setlistat *stack $store $list1
|
||||
|
||||
pusharg *stack
|
||||
call !packages/lists/lists:listremove &stack
|
||||
call !lists:listremove &stack
|
||||
|
||||
jump %increment
|
||||
|
||||
@@ -523,7 +522,7 @@ fun -double !rpn -list &rpn
|
||||
setlistat *stack $store $list1
|
||||
|
||||
pusharg *stack
|
||||
call !packages/lists/lists:listremove &stack
|
||||
call !lists:listremove &stack
|
||||
|
||||
jump %increment
|
||||
|
||||
@@ -541,7 +540,7 @@ fun -double !rpn -list &rpn
|
||||
setlistat *stack $store $list1
|
||||
|
||||
pusharg *stack
|
||||
call !packages/lists/lists:listremove &stack
|
||||
call !lists:listremove &stack
|
||||
|
||||
jump %increment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user