4

From Esolang
Jump to: navigation, search

4, named after the last digit of pi (a joke from the webcomic Homestuck), is an esoteric programming language created by user:Vriskanon.

Program overview

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.

The beginning

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.

The end

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 body

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.

FuncCode Name Variable1 Variable2 Variable3 Description
0 Add Target cell First cell Second cell The target cell becomes the value of the first cell added to the second cell.
1 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)
2 Multiply Target cell First cell Second cell The target cell becomes the value of the first cell multiplied by the second cell.
3 Divide Target cell First cell Second cell The target cell becomes the first cell divided by the second cell. (First cell / Second cell)
4 Exit N/A N/A N/A Ends the code.
5 Print Target cell N/A N/A Prints the ascii character of the target cell.
6 Set Target cell Number 00-99 N/A The target cell's value is set to the number between 00 and 99.
7 Input Target cell N/A N/A Takes a single character input and sets the value of the target cell to its ascii value.
8 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.
9 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.

Sample codes

Cat program

3.6000180071051094

Hello World!

3.699206007260181001019960288002029960391003039960499004049960594005059960680006069960733608325005015025025035085045035055025065074

External resources