18

From Esolang
Jump to navigation Jump to search

18 is an esolang created by User:Yayimhere, as a merge of 7 and ErrorBucket. 18 works in base 18, and as such it gets its name.

Data

18 uses two frames. frames is a string of symbols/tokens(specifically, 18 commands), which can be separated by a special symbol called a bar(which here will be represented by a |). One of them is called the data frame, and one is called the program frame. The data frame is read and write, and always starts with a 0x02 0x03(note that there is no bar) as the only element, while the program frame isnt, however only to the extent that I cant be read during execution, and can only be, and will always be, read at the end of the program(however not execution). Note that here, the front of the frame would be the top of the stack(ignoring whatever number of bars may be at the front). At all times, there may or may not be a frame that is selected or pointed to.

Execution + Syntax

An 18 program runs in cycles. A new cycle is started every time an old one ends. Cycles end when the program they run with ends. When a new cycle starts, the front of the bit bucket is "popped", including whatever bars may be immediately to the left or right of it, and then it is ran as the next program. Every triplet of command pairs must have at least one pair thats absolute(where there's either only passive commands or only active commands), one thats fluid(where there's one active command and one passive), and on that can be either.

Commands

In the above section two types of commands are named. These are passive and active commands. Every command has to variants, the passive and active one. The passive version of a command will append the given active version to the end of the front string of the selected queue. However, active commands vary semi-widely in their functions. Below, the active command will be on the right:

0;00, 0;0H:

The active command will append a bar to the currently selected frame.

0;01, 0;0G:

The active command pacifies the command string at the front, and deletes the bar to its left, if any. Pacification works as follows: identify the passive substrings of the list (favouring one long substring, rather than two shorter adjacent ones), prepend a 0;0H and append a 0;0G to each such substring, then convert every command outside the passive substrings (all such commands will be active) to its passive equivalent. A passive substring is a string where all 0;0H's are matched correctly with 0;0G's as brackets, and all commands are passive. This will always apply to the data frame.

0;02, 0;0F:

The active command will make the rightmost symbol of the string at the front of the data frame, be active. This is undefined behaviour if it's already active.

0;03, 0;0E:

The active command is a NOP.

0;04, 0;0D:

Checks the rightmost symbol of the symbol of the string at the front of the data frame, and will then select the corresponding frame(if its active or a 0;0F it will choose the data frame, but if its passive or 0;0E choose the bit bucket).

0;05, 0;0C:

Copy the frontmost bar separated string of the non-selected frame, not including the bars, and push a bar, and then the copied string, both to the non-selected frame. Undefined behaviour for bitbucket.

0;06, 0;0B:

Deletes the frontmost symbol(including bars) from the selected frame.

0;07, 0;0A:

Deletes the frontmost bar separated string, including the rightmost bar of it, if there's any, from the selected frame.

0;08, 0;09:

Moves the frontmost bar separated string of the selected frame to the non-selected frame. Note that a move from the bit bucket will just move a bar(two bars in the case there's no bar at the front of the data frame, else only one).

Similarity to 7 and ErrorBucket

Most 18 commands are taken from one of the two(though this doesnt actually work as translation):

0x0H -> 7
0x0G -> 6
0x0F -> a
0x0E -> b
0x0D -> f
0x0B & 0x0A -> c
0x09 -> none(original)