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: diff --git a/ZSharp/ZS.h b/ZSharp/ZS.h index 175beef..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,9 +141,71 @@ func GetKey(keyName) return b } +// WIP //func SplitThread(function) //{ // ZS.System.SplitThread(function) //} + + +////////////////////////////////////////////////////// +// ↓ MADE BY KAPUTCHINO ↓ + +// Return the number of combinations +func Comb(n, r) +{ + return Perm(n, r) / Fac(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 +} + +// Return the number of permutations +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) +} + )" -; \ No newline at end of file +;