From acaec4d40bf50d716958814a95fa9fe78c32d604 Mon Sep 17 00:00:00 2001 From: DiamondNether90 Date: Sun, 21 Sep 2025 08:18:11 +1000 Subject: [PATCH] Packages now properly work when imported --- packages/math/math.grnd | 77 +++++++++++++++++------------------ packages/strings/strings.grnd | 18 ++++---- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/packages/math/math.grnd b/packages/math/math.grnd index c9a69fb..ac37ad4 100644 --- a/packages/math/math.grnd +++ b/packages/math/math.grnd @@ -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 diff --git a/packages/strings/strings.grnd b/packages/strings/strings.grnd index a92cb10..90af92d 100644 --- a/packages/strings/strings.grnd +++ b/packages/strings/strings.grnd @@ -71,13 +71,13 @@ fun -string !inBrackets -string &str -char &left -char &right -int &instance pusharg $str pusharg $left pusharg $instance - call !findCharInstance &left + call !strings:findCharInstance &left # Get right idx pusharg $str pusharg $right pusharg $instance - call !findCharInstance &right + call !strings:findCharInstance &right # Get inner string add $left 1 &left @@ -85,7 +85,7 @@ fun -string !inBrackets -string &str -char &left -char &right -int &instance pusharg $str pusharg $left pusharg $store - call !mid &store + call !strings:mid &store return $store endfun @@ -94,7 +94,7 @@ fun -bool !matchStart -string &str -string &instr pusharg $str pusharg 0 pusharg $store - call !mid &store + call !strings:mid &store equal $store $instr &store return $store endfun @@ -183,7 +183,7 @@ fun -bool !contains -string &str -string &instr pusharg $str pusharg $idx pusharg $inlen - call !mid &store + call !strings:mid &store equal $store $instr &store if $store %true @@ -204,7 +204,7 @@ fun -list !split -string &str -string &splitstr @loop pusharg $str pusharg $splitstr - call !contains &store + call !strings:contains &store if $store %continue jump %end @@ -213,7 +213,7 @@ fun -list !split -string &str -string &splitstr pusharg $str pusharg $splitstr pusharg 0 - call !findStringInstance &store + call !strings:findStringInstance &store # Store amount of characters to remove add $store $splitlen &store2 @@ -222,14 +222,14 @@ fun -list !split -string &str -string &splitstr pusharg $str pusharg 0 pusharg $store - call !mid &store + call !strings:mid &store listappend *list $store # Remove first split pusharg $str pusharg $store2 - call !removeLeft &str + call !strings:removeLeft &str jump %loop