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