{"id":22452619,"url":"https://github.com/totaltechgeek/tsrp","last_synced_at":"2025-03-27T12:42:28.051Z","repository":{"id":148359222,"uuid":"74312271","full_name":"TotalTechGeek/TSRP","owner":"TotalTechGeek","description":"Temporary Stack Reverse Programming Language","archived":false,"fork":false,"pushed_at":"2017-02-21T16:02:23.000Z","size":134,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T17:13:45.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TotalTechGeek.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-21T00:36:21.000Z","updated_at":"2016-11-21T00:36:25.000Z","dependencies_parsed_at":"2023-05-13T02:45:40.251Z","dependency_job_id":null,"html_url":"https://github.com/TotalTechGeek/TSRP","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalTechGeek%2FTSRP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalTechGeek%2FTSRP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalTechGeek%2FTSRP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalTechGeek%2FTSRP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TotalTechGeek","download_url":"https://codeload.github.com/TotalTechGeek/TSRP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245850122,"owners_count":20682632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-06T06:11:54.612Z","updated_at":"2025-03-27T12:42:27.988Z","avatar_url":"https://github.com/TotalTechGeek.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## The TSRP Programming Language\r\n#### (Temporary Stack Reverse Programming) \r\n\r\n---\r\n\r\n``Warning: This documentation is still rather raw and was written in a few hours. Some of the descriptions might be ambiguous, and all the features might not be documented yet. There is a ton to document.``\r\n\r\nTSRP is a stack-based anonymous functional programming language (with support for many number types) designed for both academic and demonstration purposes. \r\n\r\nWhile languages like Lisp and Scheme use structured Polish Notation for their code, TSRP is designed to use a more chaotic and free Reverse Polish Notation, while sporting many of the same bragging points.\r\n\r\nIn TSRP, syntax is not tightly bound, as the language doesn't need to analyze what is valid. \r\n\r\n```\r\n{ 100 rand } 50 Repeat\t\t{ Generates 50 Random ints and Pushes them to the Stack } pop\r\n{ + } 49 Repeat\t\t\t{ Adds 49 times. } pop\r\n```\r\n\r\n---\r\n#### Reverse Polish Notation and The Stack\r\n\r\nTo understand the language, you must first understand stacks and reverse polish notation. \r\n\r\nIn a majority of cultures, math is typically written in the form \"operand operator operand\". This leads to complicated rules like PEMDAS where certain operations take priority over others.\r\n\r\nIn reverse polish notations, the operands are always written prior to the operator, so instead of being \"10 + 20\", it becomes \"10 20 +\". There are no ambiguous priority rules in RPN. \r\n\r\nStandard | RPN\r\n-- | -- \r\n10 + 20 | 10 20 + \r\n10 + 20 * 30 | 10 20 30 * + \r\n10 * 20 + 10 | 10 20 * 10 +\r\n\r\nReverse Polish Notation has been implemented in TSRP by pushing values onto a stack, and executing the operators on the top values on the stack.\r\n\r\nEverything is pushed onto the stack in TSRP, including functions.\r\n\r\nTo remove variables from the stack that you no longer need, you must type \"pop\" \r\n\r\n---\r\n\r\n#### Global Variables\r\n\r\nIn TSRP, there are two supported variable types. Local and Global variables. Let's focus on the global ones for now. Setting variables happens by peeking at the top value on the stack, and copying it to the variable space. It uses the \"=VariableName\" command. \r\n\r\n\u003cbr\u003e\r\n\r\n```\r\n10 =t \r\n```\r\n\r\nWould stick \"10\" into t. Note that it does not pop the variable off the stack. If you wish to do that, you must type \"pop\" after it, like so.\r\n\r\n```\r\n10 =t pop\r\n```\r\n\r\nTo retrieve the value for later use, you can use the \"$VariableName\" command.\r\n\r\n```\r\n$t 20 + \r\n``` \r\n\r\n---\r\n\r\n#### Functions, Ifs, Loops\r\n\r\nIn TSRP, all functions are first declared anonymously and pushed onto the stack. These functions also make it possible to implement loops and if statements. These functions can be named and run from the variable space, but can also be executed anonymously. \r\n\r\n```\r\n{ Anonymous Function Demonstration } pop\r\n20 \r\n{\r\n\t10 + \r\n} exec  \r\n```\r\n\r\nWould produce an answer of 30. Note that running \"exec\" pops the function off the stack when run.\r\n\r\nTo create a named function, you simply push an anonymous function onto a stack, and assign it a variable.\r\n\r\n```\r\n{\r\n\t10 +\r\n} =AddTen pop\r\n```\r\n\r\nTo call \"AddTen\", you have two options. You can either push it onto the stack and use a command like \"exec\" to run it (which pops it off the stack), or you can type the function name.\r\n\r\n```\r\n20 $AddTen exec\r\n\r\n{ or } pop\r\n\r\n20 AddTen \r\n```\r\n\r\nPushing functions back onto the stack can be useful for passing them around as variables, or using them in loops/ifs. \r\n\r\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\r\n\r\n\r\n\r\nTo write an if, you must push a function onto the stack, then a boolean, and run the \"if\" command.\r\n\r\n```\r\n{\r\n\t30\r\n} \r\n$x 30 \u003c\r\nif\r\n```\r\n\r\nThis function checks if x is less than 30, and if it is, push 30 onto the stack. Keep in mind that calling the \"if\" pops both the boolean and the function off the stack.\r\n\r\nElse ifs are also supported. \"{ true function } { false function } bool eif\" \r\n\r\n```\r\n{\r\n\t_=x pop _=y pop\r\n\t{\r\n\t\t_$x\r\n\t}\r\n\t{\r\n\t\t_$y\r\n\t}\r\n\t_$x _$y \u003c eif\r\n} =Min pop\r\n```\r\n\r\nThis is a simple \"Min\" function (with local variables) that takes two inputs and returns the lower value, keep in mind, however, that such a function is natively supported.\r\n\r\nFor loops, there are multiple options, you can use \"Repeat\"s, and \"while\"s. \r\n\r\nLet's start with a repeat.\r\n\r\n```\r\n0\r\n$AddTen 20 Repeat\r\n```\r\n\r\nRuns the AddTen function 20 times. The top value on the stack will be 200. \r\n\r\nYou can also specify an incrementation local variable (discussed in the next session) with the repeat call.\r\n\r\n```\r\n0\r\n{ _$c 1 + + } 20 Repeat:c \r\n```\r\n\r\nThis calculates the summation of every value from 1 to 20 (the incrementer goes from 0 to the upper-bound, exclusive). \r\n\r\nIf you wanted to create a while loop, you need two functions. One will be the inner loop code, and the other will be what produces the boolean value that is checked.\r\n\r\n```\r\n0 =x pop\r\n{ $x 1 + =x pop }\r\n{ $x 10 \u003c } while\r\n```\r\n\r\nThis while loop would increment x until it equals 10. \r\n\r\n\r\n---\r\n\r\n#### Local Variables\r\n\r\n\r\nLocally scoped variables are similar to global ones, but they have a few interesting traits. They automatically erase themselves after they fall completely out of scope. However, they are designed to have a few interesting traits. (Note that this section may require reading of the next section).\r\n\r\n```\r\n{\r\n\t_=Hello _$Hello + \r\n} =Double pop\r\n```\r\n\r\nLocal Variables are also able to travel to the functions that are called by a function, and back to the functions that called them. This allows you to pass values \"by reference\" in a sense.\r\n\r\n```\r\n{\r\n\t10 _=John \r\n\tB\r\n\t$_John +\r\n} =A pop\r\n\r\n{\r\n\t20 _=John\t\r\n} =B pop\r\n\r\nA\r\n```\r\n\r\nCalling 'A' would produce a result of 30. Note that the use of this feature isn't necessary, as you could return values simply by pushing them onto the stack.\r\n\r\nIf you wish to prevent the local variables from being modified by other functions, you can add a \"hold\" command prior to setting a local variable.\r\n\r\n```\r\n{\r\n\thold\r\n\t10 _=John \r\n\tB\r\n\t_$John +\r\n} =A pop\r\n\r\n{\r\n\t20 _=John\t\r\n} =B pop\r\n\r\nA\r\n```\r\n\r\nA would produce 20.  \r\n\r\nHowever, keep in mind that the hold only applies to local variables set in the function AFTER the \"hold\" is set.\r\n\r\nLocal Variables also travel backwards up to calling functions. This is by design.\r\n\r\n---\r\n\r\n#### Data Types\r\n\r\nThere are various data types supported. \r\n\r\nTypes | Sub-Types / Description\r\n-- | --\r\nStrings | N/A\r\nBools | N/A\r\nNumbers | Bytes, Shorts, Ints, Longs, and Unsigned Variants.\r\nArrays | N/A\r\nCustom | Extension Types that Allow Integration with the Scripting Language.\r\n\r\nHere are the methods supported for the \"primitive\" types.\r\n\r\nStrings \r\n\r\nType of Operation | Operations | Description\r\n-- | -- | --\r\nConversion | array, carray, any of the number types below, function, string | \"array\" splits the string into strings of length one, and places it into an array. \"carray\" does the same, but converts each letter into a ushort. The number types convert the string to a number. Function turns the string into a function. string does nothing to it.\r\nConditional | ==, !=, contains |\r\nInfo | len, length |\r\nOperational | +, split, trim | \r\n\r\n\r\nNumbers \r\n\r\nType of Operation | Operations | Description and Notes\r\n-- | -- | --\r\nArithmetic | +, -, *, /, %, ^ | Arithmetic Operations\r\nConditional | ==, !=, \u003c, \u003c=, \u003e, \u003e= | Conditional Operations\r\nBit-Wise | xor, or, and, \\|, \u0026, \u003c\u003c, \u003e\u003e, ~ | Not supported by floating point types\r\n\r\n\u003cbr\u003e\u003cbr\u003e\r\n\r\nType of Operation | Operations | Description and Notes\r\n-- | -- | --\r\nConversion | string, any of the number types in the list below | \r\n\r\nNumber Types |\r\n-- |\r\nbyte |\r\nsbyte |\r\nshort |\r\nushort |\r\nint |\r\nuint |\r\nlong | \r\nulong |\r\nfloat | \r\ndouble | \r\n\r\nTo convert between any of these types, you can type it in as a command.\r\n\r\n```\r\n1 2 double / \r\n```\r\n\r\nNumbers are also dynamically promoted when there are mis-matched variable types. If the variables are of the same priority (unsigned vs signed), the deeper variable of the two is the one that they are converted to. \r\n\r\n```\r\n1 uint\r\n1 int + \r\n```\r\n\r\nWould produce a 2 uint. \r\n\r\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\r\n\r\nBool \r\n\r\nType of Operation | Operations | Description and Notes\r\n-- | -- | --\r\nOperational | !, not |\r\nConditional | ==, !=, \u0026\u0026, \\|\\|, ^, or, and, xor, nor, nand |\r\nConversion | string, any of the number types above. |  \r\n    \r\n\r\nStackArray\r\n\r\nThis type has abnormal behavior in comparison to the other primitives. Unlike the others, this one does not clone itself when it is copied to the vaiable space. It is also flagged as a \"Custom\" type, which means that even if it isn't on the top of the stack, if it is the top custom type, it will execute commands.\r\n\r\n```\r\n[]\r\n10 20 push push\r\n```\r\n\r\nEven though array_push isn't a command for numbers, all commands that fail on the top data type will route to the nearest custom type, which is the array. So it pushes 20 and then 10 into itself. \r\n\r\nAlso, if you add a \"*\" to the end of any array command, if the array is the top value on the stack, it will pop itself from the stack when it completes its operation. If you add \"**\", it will remove itself from the stack once it completes its operation, regardless of how deep in it is. \r\n\r\n```\r\n[] \r\n20 30 40 push push push\r\n{ other code } pop\r\n{ other variables put onto the stack } pop\r\nempty** \r\n{ empties the array and pops it from the stack } pop\r\n```\r\n\r\nType of Operation | Operations | Description and Notes\r\n-- | -- | --\r\nOperational | empty, array_clear, array_pop, release, clone, reverse, push, array_push | empty/array_clear empties the array. array_pop pops a value from the array and sticks it onto the current stack. Release pops all the values in the array and puts it inside the stack. Clone actually creates a duplicate of the array, deep copying. \r\nConversion | chars2str, concatstr | chars2str takes all numbers in it, and converts it to a string. It ignores other data types. concatstr takes all strings inside of it, and adds them together. \r\n\r\n\u003cbr\u003e\u003cbr\u003e\r\n\r\nType of Operation | Operations | Description and Notes\r\n-- | -- | --\r\nSet/Get | at, set | at retrieves the element at a specified position in the array. set sets the element at a specified position in the array.  \r\nInfo | size | \r\n\r\nHowever, this hardly tells the full story of what is possible with the language. We'll need to talk more about parser commands and how they interact with types like the StackArray.\r\n\r\n----\r\n\r\n#### Parser Commands\r\n\r\nThe parser has a reasonably sized list of basic commands. \r\n\r\nOh, and there is a pre-processing step, so when you've seen\r\n```\r\n{ This is a comment } pop\r\n```\r\nThat actually gets trimmed from the code. \r\n\r\nCommands | Description\r\n-- | --\r\nswap | Swaps the two top elements.\r\ndup | Duplicates the top element. \r\npop, del | Pops the top element. \r\n$variableName, _$variableName | Pushes a variable onto the stack.\r\n=variableName, _=variableName | Peeks at the stack and the top element to the variable space.\r\nvariableName | If the variable is a function, it will be executed.\r\nif | Takes in a boolean and a function, executes the function if true.\r\nwhile | takes in two functions. One for generating the boolean, one which is the inner loop code. Executes while true.\r\n\r\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\r\n\r\nCommands | Description\r\n-- | --\r\nrepeat | takes in a number and a function. repeats function that number of times. You can specify an incrementation value which will be a local variable.\r\nhold | tells the function to hold onto any local variables set after the hold is declared when calling other functions (pass by value).\r\nexec, run, execute | if the top value on the stack is a function, it runs it.\r\nimport | Imports a custom type variable. This is for modules.\r\nset_hold | Takes in a boolean and toggles the hold. In the current implementation, it does not undo the \"hold\" on values that have already been set after a hold.\r\n@size | Pushes the current size of the stack onto the stack.\r\n[] | push an array onto the stack\r\n##.# | push a double onto the stack.\r\n### | push an integer onto the stack.\r\n\"text here\" | push a string onto the stack\r\ntrue, false | push a boolean onto the stack. \r\n::variableName | if the variable is a StackArray, push the size of it onto the current stack.\r\n:\u003evariableName | if the variable is a StackArray, pop the top element of the current stack and push it into this array.\r\n:\u003cvariableName | if the variable is a StackArray, pop the top element of the array, and push it to this current stack. \r\nEnter, enter | **These features might be confusing.** If the top element of the stack is a StackArray, \"enter\" it, and use it as the current stack. All operations inside it will modify the array, but not affect the previous stack.\r\nExit, exit, Leave, leave | If you are currently inside another stack, these commands will take you back to the previous stack you were in.\r\n[ | Enter a new stack.\r\n] | If you are currently in another stack, using this command will return you to your previous stack and push the current one onto your previous stack as a StackArray.\r\n      \r\nDemonstrating \"Switching\" Stack Features\r\n\r\n```\r\n[\r\n\t{ 100 rand 1 + } 100 Repeat\r\n] =arrayOfIntegers pop\r\n\r\n{ This creates an array with 100 Random integers ranging from 1 to 100. } \r\n```\r\n\r\nLet's say you already have an array though, and you wanted to do some processing on it. You could push and pull from it, or you could enter the array and modify it. \r\n\r\n```\r\n{ In this example, you have an array of integers, and you want to add them all together to become one, then push that value onto the original stack. } pop\r\n\r\n$arrayOfIntegers\r\nEnter \r\n{\r\n\t+\r\n}\r\n@size 1 - Repeat \r\nLeave \r\nrelease**\r\n```\r\n\r\n\r\nYou can also push and pull from named arrays with ease using the \":\u003e\" and \":\u003c\" commands. Here is an alternative to the previous example.\r\n\r\n```\r\n0\r\n{\r\n\t:\u003carrayOfIntegers +\r\n}\r\n::arrayOfIntegers Repeat\r\n```\r\n\r\nAlso, you can use these tricks to be lazy about cleaning up your stack during processing and setting up variables, for example\r\n\r\n```\r\n[\r\n\t{ 10 + } =AddTen\r\n\t{ AddTen AddTen } =AddTwenty\r\n\t{ AddTwenty AddTen } =AddThirty\r\n\t{ AddTwenty AddTwenty } =AddForty \r\n\t{ bunches of other declarations } pop\r\n] pop\r\n``` \r\n\r\nNow we need to discuss Extensions / Custom types.\r\n\r\n----\r\n\r\n#### Custom Types, Extensions, and Imports\r\n\r\nNow that features of the language have been discussed, it should be noted that the language is not capable of doing much (aside from calculation) without a few extensions. TSRP was designed to be easy to extend, simply by creating a new custom type. Two are built in with the language by default (Console and System). \r\n\r\nAs mentioned earlier, custom types do not have to be the top variable on the stack to have commands executed on them. If a command fails on the top element, it will then send the command to the closest custom element. \r\n\r\nYou are also able to \"import\" custom types, so that they don't even need to be on the stack for variables to be executed on them. Keep in mind that imported types have the lowest priority. (The import command pops the type off the stack)\r\n\r\n---\r\n\r\n#### Console I/O\r\n\r\nThe console type allows you to accept input and give output through the console (somewhat obviously). Here are its commands:\r\n\r\nCommands | Description \r\n-- | -- \r\nWriteLine | takes a string and writes it to the console with a new line appended.\r\nWrite | takes a string and writes it to the console.\r\nRead | Reads a line of user input (when they hit enter)\r\nReadChar | Reads in a single character the user types into the console.\r\n\r\nHere is an example Hello World Program *(finally, am I right?)*\r\n  \r\n```\r\n$Console import \r\n\r\n\"Hello World\" WriteLine\r\n```\r\n\r\nNow let's go a bit more complicated, and take in user input.\r\n\r\n```\r\n$Console import\r\n\r\n\"Hello, \" \r\nRead \r\n+ \"!\" + WriteLine\r\n```\r\n\r\nThis code will output \"Hello, \u003cwhatever the user types in\u003e!\"\r\n\r\nLet's make it a bit more complicated\r\n\r\n```\r\n$Console import\r\n{ \"Hello, \" swap + \"!\" + WriteLine } =Greet pop\r\n\r\n\"Type in your name : \" Write Read Greet\r\n```\r\n\r\nThis will prompt the user for their name, then greet them appropriately. \r\n\r\nWhat if you wanted to read in integers? Well, just convert the string!\r\n\r\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\r\n\r\n```\r\n$Console import\r\n\r\nRead { Read something in } pop \r\nint  { convert it to an int } pop\r\n\r\nRead int  { Read in a second number } pop\r\n\r\n+ { Add them } pop\r\nstring WriteLine { Convert it to a string and write it to the console } pop \r\n```\r\n\r\nThat's really all there is to it. Command Line I/O is pretty easy with TSRP. \r\n\r\n---\r\n\r\n#### File I/O \r\n\r\nBut what if you wanted to do file input and output?\r\n\r\nWell, first you'd import system (or push it onto the stack), then you open a file.\r\n\r\n\r\nFile Supported Commands | Description | Status \r\n-- | -- | --\r\nRead | Reads a single character  | Supported\r\nReadLine | Reads a line. | Supported\r\nWrite | Writes a String | Supported\r\nWriteLine | Writes a String with a new line character | Supported\r\nCheckLine | Checks if there are more lines | Supported\r\nReadToEnd | Reads all the text to the end of the file | Supported\r\nReadWord | Reads a single word | Supported\r\nClose | Closes the File | Supported\r\nReadByte | Reads a single byte (as a byte) | Experimental \r\nReadBytes | takes in a digit, and reads that many bytes to an array | Experimental\r\nWriteByte | takes in a byte, and writes it to the file | Experimental\r\nWriteBytes | Takes in an array of bytes, and writes it to the file | Experimental\r\nCheck | Checks if there are more bytes to be read | Experimental\r\n\r\n``Experimental indicates that the code probably works, but hasn't been well-tested.``\r\n\r\n```\r\n$System import \r\n\r\n\"data.txt\" open_file\r\n\r\n{\r\n\t\"Hello!\" WriteLine\r\n} 20 Repeat\r\nClose pop\r\n```\r\n\r\nOutput is fairly similar to the console, except you need to close the file when you're done. \r\n\r\n``Todo: Add the ** feature to Closing the File``\r\n\r\nIf you had a bunch of lines with different numbers, and you wanted to add them, here is a program you could write. \r\n\r\n```\r\n$System import\r\n$Console import \r\n\r\n\r\n\"data.txt\" open_file\r\n0\r\n{\r\n\tReadLine int + \t\r\n}\r\n{ \r\n\tCheckLine\r\n} \r\nwhile \r\nClose swap pop\r\nstring WriteLine { this would work since the file has been popped off and close } pop\r\n```\r\n\r\nNow let's say you wanted to do multiple I/Os at once, but didn't want to think about swapping variables and order and pushing and popping. Here is an area where the stack switching techniques can help. \r\n\r\n```\r\n$System import\r\n[ $Console ] =Cons pop\r\n[ \"data.txt\" open_file ] =File pop \r\n\r\n{\r\n\t:\u003eFile\r\n\t$File Enter Write Exit pop\r\n} =WriteF\r\n\r\n{\r\n\t:\u003eCons\r\n\t$Cons Enter Write Exit pop\r\n} =WriteC\r\n\r\n\r\n{\r\n\t:\u003eFile\r\n\t$File Enter WriteLine Exit pop\r\n} =WriteLineF\r\n\r\n{\r\n\t:\u003eCons\r\n\t$Cons Enter WriteLine Exit pop\r\n} =WriteLineC \r\n\r\n{ pop } 4 Repeat\r\n\r\n\r\n{ \r\n\t\"Hello\" WriteLineC \r\n\t\"Hello\" WriteLineF\r\n} =M\r\n\r\nM M M \r\n```\r\n\r\nOf course, there are other options for writing those methods, too.\r\n\r\n---\r\n\r\n#### Other System Features\r\n\r\n\r\nSystem has support for these commands\r\n\r\nCommands | Description\r\n-- | --\r\nopen_file | Opens a file for input/output.\r\ncall_windows | Takes in a string and makes windows command prompt calls.\r\ncall_program | Takes in two strings, one is an executable name, the other is the arguments. It will execute the program with those arguments.\r\n\r\nYou can use call_windows and call_program to open other programs.\r\n\r\nExample\r\n\r\n```\r\n$System import \r\n\"program.jar\" \"-f James -l Dowthitt\" call_program\r\n```\r\n\r\n---\r\n\r\n#### Misc Programs (Examples)\r\n\r\n\r\n\r\n**Simple Fibonacci Term Computation**\r\n(input of 46 produces all values calculatable by an unsigned long)\r\n\r\n```\r\n$Console import \t\r\n\r\nRead int =times \t\r\n\r\n0 =counter\t\t \t\r\n{ $counter 1 + =counter 1 - \" \" + Write } =WriteCounter \r\n\r\n{ string WriteLine } =Print\t\r\n\r\nWriteCounter 0 ulong =n_0 Print  \r\nWriteCounter 1 ulong =n_1 Print \r\n\r\n{ WriteCounter $n_0 $n_1 + =n_0 Print } =A \r\n{ WriteCounter $n_0 $n_1 + =n_1 Print } =B \r\n\r\n{ A B } $times Repeat\r\n \r\n{ pop } \r\n{ @size 0 != } while \r\n```\r\n\r\n**Funny Complex Fibonacci Computation *(practically unreadable)***\r\n\r\n```\r\n$Console import\r\n\r\n2\r\n{ A B } Read int\r\n{ dup \" \" + Write 1 + } =W\r\n{ \"\" + WriteLine } =d\r\n0 ulong =a \r\nW 0 d \r\nW 1 =b d\r\n{ W $a $b + } =Q \r\n{ Q =a d } =A\r\n{ Q =b d } =B\r\n{ pop } =e 6 Repeat Repeat e\r\n```\r\nNotice how the second Repeat near the bottom is loosely couples with the anonymous function { A B } and the number produced by \"Read int\" at the top.\r\n\r\n**High Low Guessing Game**\r\n```\r\n$Console import\r\n\r\nFalse =Q pop\r\n\r\n50 =Z rand 1 + =value pop\r\n\r\n{\r\n\t\"Guess a value between 1 and \" $Z + \" -\u003e \" + Write\r\n\r\n\r\n\r\n\tRead int =x pop\r\n\t\r\n\r\n\t{\r\n\t\t{ \"Higher\" }\r\n\t\t$x $value \u003c if\r\n\r\n\t\t{ \"Lower\" }\r\n\t\t$x $value \u003e if\r\n\r\n\t\t{ \r\n\t\t\t\"Good Job!\" \r\n\t\t\tTrue =Q pop\r\n\t\t}\r\n\t\t$x $value == if\r\n\t\r\n\t\tWriteLine\r\n\t}\r\n\t{\r\n\t\t\"Invalid Value, out of range.\" WriteLine\r\n\t}\t\r\n\t$x 1 \u003e=\r\n\t$x $Z \u003c= \r\n\tand \r\n\teif\r\n\r\n\r\n\r\n\t\"\" WriteLine\r\n}\r\n{ $Q ! } \r\nwhile \r\n\r\n\r\n\"The correct value was \" $value + \".\" + WriteLine\r\n```\r\nNotice how in this example that the result string is pushed to the stack, then WriteLine is called, rather than it saying { \"Higher\" WriteLine }, { \"Lower\" WriteLine }. These are little programming tricks that are possible.  \r\n\r\n\r\n**Lottery Numbers (6 Numbers, 1-100, No Overlap)**\r\n```\r\n$Console import\r\n\r\n[] =Nums pop\r\n[ { _$c } 100 Repeat:c ]\r\n{\r\n\t{\r\n\t\t_$q :\u003eNums\r\n\t}\t\r\n\tsize rand _=s at \r\n\t_=q 1 \u003e \r\n\tif\r\n\t\r\n\t-1 _$s set\r\n}\r\n{\r\n\t::Nums 6 \u003c\r\n}\r\nwhile\r\nempty**\r\n{ :\u003cNums \" \" + Write } 6 Repeat:c\r\n```\r\n\r\n**Square Numbers**\r\n\r\n```\r\n$Console import\r\n{ _$c 1 + 2 ^ \"\" + WriteLine } 20 Repeat:c\r\n```\r\n\r\nPrints out all square numbers from n=1 to n=20. \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotaltechgeek%2Ftsrp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftotaltechgeek%2Ftsrp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotaltechgeek%2Ftsrp/lists"}