Ample
Ample is a Length-like esoteric programing language created by User:hajunsheng
Syntax
Just like in Length, any op code is length of a seperated string. However instead of newlines, you split the program using dots (e.g. a.bc.def
is [1, 2, 3]
)
Commands
The language has an accumulator and a queue which can be offset into, which starts at 9.
Opcode | Effect |
---|---|
0 | NOP |
1 | print the accumulator |
2 | set the accumulator (see details) |
3 | input a character into the accumulator |
4 | conditionally skip the next opcode (see details) |
5 | jump to start |
6 | set the queue offset to the next opcode |
7 | append the accumulator to the queue |
8 | delete the offset-th item from the queue |
9 | set the accumulator to the offset-th item in the queue |
any length 10 or more | NOP |
There are two skip behaviors, depending on the first character of the next opcode segment.
- If it starts with
/
as inabcd./2
then skip the next command if the accumulator is the value after/
(2 inabcd./2
) - If it starts with anything else then skip if the value after the first is not equal to the accumulator (e.g. for
abcd.a3
will skip if the accumulator is 2)
The opcode which is skipped or not is embedded with the conditional component of the next opcode. The command immediately following a 4 can be thought of as having its length decreased by 2. For instance in abcd.a31.11111
is effectively 4[=3], 1, 5 or:
while True: if accumulator == 3: print(accumulator)
Computational class
P.S. Some codes provided may not work.
Ample can implement Bitwise cyclic tag.
The start of the translated program sets the queue offset to the start with 123456..
and initializes the queue as a single 1 (if the accumulator is not 2) with 1234./212.1.1234.e11234567
.
The zero (pop) command is implemented with opcode 8 12345678
.
For 11 the command gets the first element from the queue, then conditionally appends it if it is 1.
- set accumulator to start of queue
123456789
- if accumulator is 1, then push it to the queue
1234.e11234567
For 10 the command needs to invert 0 and 1. To do this it turns 0 to 2 and 1 to 0.
- set accumulator to start of queue
123456789
- if accumulator is 0, then set it to 2
1234.e012.2.
- if accumulator is 1, then set it to 0
1234.e112.0.
- if accumulator is 0, then push it to the queue
1234.e01234567
This method is not perfect, the values to be set will be executed if any of the branches fail. Since one of them will fail, 0 will always print. Since IO is irrelevant to Turing completeness, this is a satisfactory no-op.
At the end the accumulator is set to 2 (to prevent reinitialization) and a jump to start is used 12.2.12345
.
The stack is empty at the start. To remedy this the accumulator is to be set to some non-default value at the end of the loop, just before the jump. At the beginning of the loop a check if the non-default value is set or not, if not, then the accumulator is set to 1, then if the accumulator is 1, it is pushed. The non-default value has to be something other than one. The scheme here uses 2, as in the 0 command.
If given a cyclic tag program with in the form (prod;prod;...)
the following character wise substitution can be used:
(
123456..1234./2aa.1.1234.e11234567.
;
12345678.
1
123456789.1234.e11234567.
0
123456789.1234.e012.2.1234.e112.0.1234.e01234567.
)
ab.2.12345
This construction should allow for a minimal source code symbol type count of 4, one for the dots, one for 1, one for 0, and one for /. The slash serves triple duty as the conditional operator, non-default accumulator value, and temp value for the 0 BCT command.