Ample
Ample, ahh yes another another another esolang by User:hajunsheng that i have to make a documentation for. ok its basically length but with its own features. scratch project
Commands
uhh no they aren't fixed but uhh maybe later look down
Usage
use any character and amount of characters followed by a dot(".") for it.
E.g. abc.defghi.11111.2.a.
is interpreted as the list of opcodes 3, 6, 5, 1, 1, 0.
Actual commands
i will make commands like lengths ok:
0 will wait for a moment.
1 will print var.
2 will set var like "nm.x" sets var to x.
3 will get one character of user input and store in var.
4 will check if var = next but with / its if not then it will skip next if false like "1234.nx12.y" will set var to y only if it is x but "1234./x12.y" will set var to y only if var isn't x.
5 will reset code pointer.
6 will set stack pointer to the amount like "123456.123456789" will set stack pointer to 9.
7 will add var to stack.
8 will delete the stack pointer pointer item from stack.
9 finally will set var to the stack pointer pointed item in stack.
As implemented
The language has an accumulator and a queue which can be offset into, which starts at 9.
Opcode | Effect |
---|---|
0 | wait/sleep for 300 ms |
1 | append the accumulator to output |
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 | do nothing |
The set command alters the code pointer. When called, it will assign the accumulator to the first character in the next opcode's string. E.g. the program 11.a
will set the accumulator to a
. However, the set command alters the code pointer such that the next command executed is 2 away from where it would otherwise. For instance 11.a.11111
never prints the accumulator, it sets it, then jumps to the beginning.
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)
Usefulness
maybe more commentable? idk.
Warning
some codes provided may not work.
Computational class
Ample can potentially implement bitwise cyclic tag.
The start of the translated program sets the queue offset to the start with 123456..
.
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
At the end a jump to start is used 12345
.
The only issue with the logical behavior of this is that the stack is uninitialized at the start, and it is not clear how to initialize it in a stable manner.