Quiney

From Esolang
Jump to: navigation, search

Quiney is a tape programming language, like BF (Both in commands and style), whose variable system and commands are stored on the same, one-dimensional, infinitely long (in one direction) array, which can store the numbers 0 through 9. It was developed by User:Nathanator1416j. These numbers, for human readability, are actually commands that are commonly written as their representative characters. The commands in Quiney are as follows:

0 " " Null character. Basically as if command didn't exist, but it is used as a marker, as it is the only character that allows escape from "[" and "]"
1 "[" The exact same as in the BF language.
2 "+" Rotates the selected value up one unit. (Roll over after 9).
3 "." Outputs the data selected by the cursor.
4 "}" Moves the data editor cursor forward one cell.
5 "{" Moves the data editor cursor back one cell.
6 "," Take an input to the selected cell.
7 "-" Rotates the selected value down one unit. (Roll over after 0).
8 "]" The exact same as in the BF Language.
9 "*" Invert the character. Ex. 0 to 9, "[" to "]".

The selected cell in the initiation of any program is the first. This allows for the one command, one character quine, "."

Interpreter Regulations

Besides past stated regulations, when a program runs, the only errors that should come up are a wrong number of close brackets trying to be executed. If extra brackets exist, but are behind or in front of the program and wont be executed, there need be no error. For example, the below program should run because the end bracket is never read. Programs who create brackets which aren't read are also OK. If a command moves the data cursor past the last command, a new command is made, and set to " ".

"+[*]]"

When a "," is executed, the interpreter should ask for a value, 0 through 9 (representing a command) or any command character.

Cellular Automaton

Quiney could be used as cellular automaton, mainly because it can systematically edit itself (by it's own rules).

Examples

Code is surrounded in quotes, to preserve the visibility of the space character.

Quines

The One Command Quine

"."

Quine-Six Char.

".[}.] "

Eight Char.

".}[.}]. "

Eight Char. Quine With Two Null

" .+[}.] "

Six Char.

"[.}]. "

Seven Char Quine

".[}.]} "

An n + 7 Quine

".[}.]}" (Repeating "}" or "{" can be inserted here) " "

Self Modifying

These programs self modify, morph, or destruct

Self Destruct (one Char)

"*"

Self Mutating program

"[ }]}[}]+[{]+[}[-]+] "

Which gets stuck in an infinite loop state, oscillating between the two states below:

"[[[[[[[[[[[[[[[[-]+]]"
"[[[[[[[[[[[[[[[ -]+]]"

Oscillators

only the first phase can be executed, the rest are visuals of the code state, their pointers aren't at cell 1.

Small Oscillator, 2 phase

"[[[-]+]]"
-other phases
" [[-]+]]"

Midsize Oscillator 4 phase

"[ }}[}]++ [-][{]]"
-other phases
"[ }}[}]++[[-][{]]"
"[ }}[}]+++[-][{]]"
"[ }}[}]++.[-][{]]"

Interpreters

You Decide (Simple, almost useless interpreter) The smallest interpreter, possibly ever. Fragile.

"[}]}[ ,]"
This has two useable, reasonable commands, "-", possibly a wait, turns into a ","
and a "," which asks for another input.
A space would knock the program into infinite loop,
and the "*" would do the same after the equivalence of one wait.
A close bracket would also loop infinitely after a period of one wait.
An open bracket would cause an almost instant error.
"." would cause an infinite output of itself, which could be considered a quine,
and a "+" would turn into a "." and continue outputting "."s
"{" would move the cursor to a null, causing the loop to stop and the program to end.
"}" would eventually move the cursor to a null character and end the program.

More Complex Interpreter Has different "Phases", initial program is Phase 1, other phases can be entered with certain commands.

"[}]{[}, {]"
-
---Phase 1---
Program will continue to take input after each command unless otherwise noted.
Null does nothing. "[" Creates error.
"," Asks for another input, but does nothing, possibly a "Skip next command".
"-" turns itself into a "," but doesn't ask for input, does nothing.
A "." prints a "." to the output.
A "+" turns into a ".", but does nothing.
A "]" Moves program to phase 2.
When a "*" is entered, it uses up one rotation.
"{" delays the interpreter one rotation.
"}" puts the interpreter into phase 3.
-
---Phase 2---
Almost a perfect self interpreter program (For Quiney)! Once the "]" has
been entered to get to this phase, one can enter a Quiney program with only a
few specific rules. As long as there are no spaces in the Quiney program being
inputted, one can simply type it in, and end it with a null character. For example:
"][.}]. "
can be typed in from the beginning of this interpreter to execute the Quiney program: 
"[.}]. "
-
---Phase 3---
A "{" Will put the interpreter into stage 4.
A "}" will end the interpreter.
A "[" will cause an error.
When a "]" is entered, interpreter enters phase 5.
-
---Phase 4---
A "]" must first be entered, else the program will crash. After the program receives this,
it enters phase 2. Although the actual code being executed is different, the interpreter
after the close bracket in Phase 4 and in Phase 2 are essentially the same.
-
---Phase 5---

This description is a WIP.

Computational class

Quiney is Turing complete, as brainfuck with decimal digit cells can be reduced to it.

Brainfuck Quiney Remarks
Beginning of program " * [ * } } * ] * } }" Moves cursor to end of brainfuck program representation. To support this, the

program representation is filled with alternating spaces.

End of program " } [ } } } ] - - } - - } [ [** " Moves cursor past end of used tape, adds "]]", then jumps across it. The "** " are the pre-initialized first brainfuck tape cell.
> " } [ * } * { ] * } * }" Each brainfuck tape cell takes 3 Quiney cells: First a "*" mark to allow the end of program code to seek to the end; then a reversed data cell to ensure the brainfuck tape area has no unbalanced Quiney loops; then a cell containing the actual data.
< " { { {"
+ " + { - }"
- " - { + }"
. " ." These work pretty much as in brainfuck, except for the

alternating spaces.

, " ,"
[ " ["
] " ]"