From ba92119cfe7e064852417981990afefba8345cc9 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Wed, 25 May 2022 11:10:56 -0400 Subject: [PATCH 1/4] Add DLL requirements for windows --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73d91cf..3a8d766 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,13 @@ Downloading or installing is very simple, here is how depending on your version 1. Navigate to [the most recent release](https://github.com/sam-astro/Z-Sharp/releases) and download `ZSharp-Win-Installer.zip`. 2. Unzip `ZSharp-Win-Installer.zip` and open the unzipped folder. 3. Inside is a single file titled `ZSharp-Setup.exe`. Run it, and follow the setup instructions. -4. Now that it is installed, there are a few ways to use it: +4. If it fails to run, make sure the `MS Visual Runtime and MSVC C++ Redistribute` are installed. You can download them [here from Microsoft](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist) +5. Now that it is installed, there are a few ways to use it: * (recommended) Any ZSharp file that ends with .ZS will automatically be associated with the interpreter. Just double-click it, and the interpreter will run. * Drag and drop any .ZS script directly onto the executable. * Use command line, providing path to interpreter and then to script like so: `> ./ZSharp.exe ./Pong-Example-Project/script.zs` -5. Feel free to use and edit the `Pong-Example-Project`. It is a single script called `script.zs`, and you can open it with any of the methods above. It is also located on the releases page. +6. Feel free to use and edit the `Pong-Example-Project`. It is a single script called `script.zs`, and you can open it with any of the methods above. It is also located on the releases page. > If you don't want to install ZSharp on your device, or you want easier acces to the executable and .DLLs, another version is provided called `ZS_Win_Base_Raw.zip`. This just contains all of the files the installer puts on your computer. ### Linux 1. Install requirements: From 7d7033cd615b0c1320e00ce8efb619532d40afe2 Mon Sep 17 00:00:00 2001 From: Kaputchino <61330453+Kaputchino@users.noreply.github.com> Date: Wed, 25 May 2022 18:56:07 +0200 Subject: [PATCH 2/4] add functions --- ZSharp/ZS.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/ZSharp/ZS.h b/ZSharp/ZS.h index 175beef..c5956e8 100644 --- a/ZSharp/ZS.h +++ b/ZSharp/ZS.h @@ -142,5 +142,64 @@ func GetKey(keyName) //{ // ZS.System.SplitThread(function) //} + +//Function made by Kaputchino + +//return the number of combinaison + +func Comb(n, r) +{ + return Perm(n ,r) / Fac(r) +} +//return the number of permutation + +func Perm(n, r) +{ + if n < 0 + { + ZS.System.PrintLine("n muss be superior or equal to 0") + return -1 + } + if r < 0 + { + ZS.System.PrintLine("r muss be superior or equal to 0") + return -1 + } + if r > n + { + ZS.System.PrintLine("r muss be inferor or equal to n") + return -1 + } + return Fac(n) / Fac(n - r) +} +//return the factorial of a number + +func Fac(x) +{ + int r = 1 + while x > 1 + { + r = r * x + x = x - 1 + } + return r +} +//return exp(x) by using the taylor method, not extremly accurate + +func TaylorExp(x) +{ + float sum = 0 + float term = 1 + int i = 1 + float sumterm = 1 + while sum != sumterm + { + sum = sumterm + term = term * x / i + i = i + 1 + sumterm = sumterm + term + } + return sum +} )" -; \ No newline at end of file +; From 7ce2d39b93a8babba49e926bde1ba8cf52d738f0 Mon Sep 17 00:00:00 2001 From: Kaputchino <61330453+Kaputchino@users.noreply.github.com> Date: Wed, 25 May 2022 19:02:29 +0200 Subject: [PATCH 3/4] sort correctly the added functions --- ZSharp/ZS.h | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/ZSharp/ZS.h b/ZSharp/ZS.h index c5956e8..46a5ccd 100644 --- a/ZSharp/ZS.h +++ b/ZSharp/ZS.h @@ -151,27 +151,7 @@ func Comb(n, r) { return Perm(n ,r) / Fac(r) } -//return the number of permutation -func Perm(n, r) -{ - if n < 0 - { - ZS.System.PrintLine("n muss be superior or equal to 0") - return -1 - } - if r < 0 - { - ZS.System.PrintLine("r muss be superior or equal to 0") - return -1 - } - if r > n - { - ZS.System.PrintLine("r muss be inferor or equal to n") - return -1 - } - return Fac(n) / Fac(n - r) -} //return the factorial of a number func Fac(x) @@ -201,5 +181,28 @@ func TaylorExp(x) } return sum } + +//return the number of permutation + +func Perm(n, r) +{ + if n < 0 + { + ZS.System.PrintLine("n muss be superior or equal to 0") + return -1 + } + if r < 0 + { + ZS.System.PrintLine("r muss be superior or equal to 0") + return -1 + } + if r > n + { + ZS.System.PrintLine("r muss be inferor or equal to n") + return -1 + } + return Fac(n) / Fac(n - r) +} + )" ; From b321a36b7d8158e8c9f2a8817eae510bd533251b Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Wed, 25 May 2022 15:20:17 -0400 Subject: [PATCH 4/4] Fix formatting, spelling --- ZSharp/ZS.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ZSharp/ZS.h b/ZSharp/ZS.h index 46a5ccd..7c80341 100644 --- a/ZSharp/ZS.h +++ b/ZSharp/ZS.h @@ -3,6 +3,9 @@ using namespace std; std::string ZSContents = R"( +//////////////////////////////////////////////////////////////////////////////// +// ↓ DEFAULT BUILTIN ↓ + // Default variables, can be overwritten // if re-initialized or changed float PI = 3.14159265358979323846264338 @@ -138,22 +141,23 @@ func GetKey(keyName) return b } +// WIP //func SplitThread(function) //{ // ZS.System.SplitThread(function) //} -//Function made by Kaputchino -//return the number of combinaison +////////////////////////////////////////////////////// +// ↓ MADE BY KAPUTCHINO ↓ +// Return the number of combinations func Comb(n, r) { - return Perm(n ,r) / Fac(r) + return Perm(n, r) / Fac(r) } -//return the factorial of a number - +// Return the factorial of a number func Fac(x) { int r = 1 @@ -164,8 +168,8 @@ func Fac(x) } return r } -//return exp(x) by using the taylor method, not extremly accurate +// Return exp(x) by using the taylor method, not extremly accurate func TaylorExp(x) { float sum = 0 @@ -182,8 +186,7 @@ func TaylorExp(x) return sum } -//return the number of permutation - +// Return the number of permutations func Perm(n, r) { if n < 0