4 is a grid-based language made up of 100 cells found on a 10x10 grid. Each cell is an integer variable. Their location is described by its X value (0-9) and its Y value (0-9), so the top left cell is 00 and the bottom right cell is 99. All cells have a default value of 0.
Parts of the program
All codes in 4 are made up of 3 parts: The beginning, the end and a main 'body' of functions.
All 4 codes start with "3.". This does not affect the code. If a code does not begin with "3.", it is considered a syntax error.
All 4 codes end with "4". This does not affect the code. If a code does not end with "4", it is considered a syntax error.
The main bulk of a code will be the body of many function. Functions are made up of 1-4 parts: The function name and 0-3 variables. All function names are 1 digit long (0-9) and all variables attached to them are exactly 2 digits long (00-99).
For example, a code that assigned the value 01 to the cell at 00 would look like this (the spacing is uneccessary, it is simply for aesthetics - it is poor form to have any non-number characters in one's code).
3. 6 00 01 4
Here the code starts with 3., then has one function, 6, which has the variables 00 and 01 attached, followed by 4.
||Add||Target cell||First cell||Second cell||The target cell becomes the value of the first cell added to the second cell.|
||Subtract||Target cell||First cell||Second cell||The target cell becomes the value of the second cell subtracted from the first cell. (First cell - Second cell)|
||Multiply||Target cell||First cell||Second cell||The target cell becomes the value of the first cell multiplied by the second cell.|
||Divide||Target cell||First cell||Second cell||The target cell becomes the first cell divided by the second cell. (First cell / Second cell)|
||Exit||N/A||N/A||N/A||Ends the code.|
||Target cell||N/A||N/A||Prints the ascii character of the target cell.|
||Set||Target cell||Number 00-99||N/A||The target cell's value is set to the number between 00 and 99.|
||Input||Target cell||N/A||N/A||Takes a single character input and sets the value of the target cell to its ascii value.|
||Begin loop||Target cell||N/A||N/A||If the target cell's value is 0, the code skips to the corresponding loop end. Otherwise, it enters the loop.|
||End loop||N/A||N/A||N/A||If the code is in the loop, it sends it back to the beginning of the loop.|