QO
Paradigm(s) | imperative |
---|---|
Designed by | SplittyDev |
Appeared in | 2015 |
Dimensions | one-dimensional |
Computational class | Turing complete |
Major implementations | Original |
Influenced by | Brainfuck |
File extension(s) | .qo |
- The title of this article may well be qo, due to typically being lowercased except, often, at the start of a sentence.
qo is an esoteric programming language inspired by Brainfuck and made by SplittyDev. qo is like a stack-based Brainfuck.
Language overview
qo operates on an array of memory cells, also referred to as the tape, each initially set to zero. It also has a stack. There is a pointer, initially pointing to the first memory cell. The commands are:
Command | Description |
---|---|
>
|
Move the pointer to the right |
<
|
Move the pointer to the left |
+
|
Increment the memory cell under the pointer |
-
|
Decrement the memory cell under the pointer |
*
|
Doubles the cell value |
/
|
Halves the cell value |
.
|
Output the character signified by the cell at the pointer |
,
|
Input a character and store it in the cell at the pointer |
:
|
Pushes the value of the cell to the stack |
;
|
Pops an item from the stack and sets the cell to its value |
[
|
Jump past the matching ] if the cell under the pointer is 0
|
]
|
Jump back to the matching [ if the cell under the pointer is nonzero
|
(
|
Jumps to the location after the matching ) if the top of the stack is zero |
)
|
Jumps to the location after the matching ( if the top of the stack is not zero |
&
|
Duplicates the element on top of the stack on the stack |
\
|
Switches the element on top of the stack with the element underneath |
^
|
Sets the cell pointer to the value on top of the stack (and pops it) |
#
|
Counts the elements on the stack and writes the result to the cell |
'
|
Starts a comment that ends at the next line break |
@
|
Reverses stack contents |
a-zA-Z!?
|
Pushes the ASCII value of the char on the stack |
%
|
Sets the cell to the value of the program counter, incremented by one |
$
|
Sets the program counter to the value of the cell |
_
|
Sets the cell to the location of the end of the program |
=
|
Sets the cell to one if the top two values on the stack are equal, zero if not; Pops the top two values from the stack |
All characters other than ><+-*/.,:;[]()&\^#'@a-zA-Z!?%$_
should be considered comments and ignored.
History
qo was invented by SplittyDev in 2015, and is a weird little programming language, extending brainfuck with interesting new features and a stack. Even though it is derived from brainfuck and even compatible with it, it would be wrong to say that it is just another brainfuck clone. It's something completely new, with endless possibilities.
It is a wonderful language with a terrible syntax, made to counter the language JacobFck.
Examples
Hello, World!
This program prints out the words Hello World!:
Hello ' push 'H' 'e' 'l' 'l' 'o' on the stack ++****: ' push a space char on the stack (0x20) world! ' push 'w' 'o' 'r' 'l' 'd' '!' on the stack @ ' reverse the stack contents # ' count the elements on the stack [ ' loop until cell value is 0 >;. ' switch to another cell, pop a letter and print it <- ' switch to the counter cell and decrement its value ] ' end loop
The same program in minimised form:
Hello++****:world!@#[>;.<-]
Move value
This code piece moves the value of the current cell (cell0) two cells to the right (cell2):
:[-]>>;
With indentation and comments the same code looks like this:
Code: Pseudo code: : Pushes the value of cell0 to the stack [-] Set cell0 to 0 >> Move the pointer to cell2 ; Pops the stack and sets the cell to its value
Cat
A cat program writes its input directly to its output. As there is not a standard way to handle EOF in qo, there are four versions of the program below, labelled by how they match common implementations of the interpreter. (see Implementation issues).
EOF returns 0:
,[.,]
EOF returns -1:
,+[-.,+]
No change on EOF, or EOF returns 0:
,[.[-],]
No change on EOF, or EOF returns -1:
,+[-.[-]-,+]
Memory and wrapping
The memory should have a size of at least 30,000 32-bit integers. The stack should have a size of at least 512 32-bit integers. The source code should be treated as Unicode character stream if possible, ASCII otherwise. Ignore everything starting from a ' character until encountering line feed. Don't wrap cells by default, but provide an option to do so.
Algorithms
See Brainfuck algorithms, Brainfuck constants.
See also
- EsoInterpreters, featuring several brainfuck interpreters written in other esoteric languages
- BFBASIC, a Basic to brainfuck compiler
- C2BF, a partially implemented C to brainfuck compiler
- Binary lambda calculus, featuring an 829 bit (under 104 bytes) Brainfuck interpreter
- Brainfuck algorithms
- Brainfuck constants
- Brainfuck bitwidth conversions
- BF instruction minimalization
- Brainfuck code generation
- Brainfuck implementations
- BFO, the first known brainfuck to brainfuck optimizer and compressor
- Category:Brainfuck, a collection of brainfuck related articles on this wiki
- Category:Brainfuck derivatives, languages based on brainfuck