Length

From Esolang
Jump to navigation Jump to search

Length is an esoteric programming language created by user:Nailuj29. Its instructions are the length of the lines, so you can hide a Length program in any other program.

Instruction Set

Line Length Name Description
9 inp Pushes the ascii value of the first byte of stdin to the stack.
10 add Pops the top two values from the stack and pushes their sum onto the stack.
11 sub Pops value A from the stack and then value B. Pushes value B - A onto the stack.
12 dup Duplicates the top value of the stack.
13 cond Pops the top value from the stack. If it is 0, skip the next instruction. If the instruction to be skipped is gotou or push, skip that instructions argument as well.
14 gotou Sets the program counter to the value of the line under the instruction, skipping that line.
15 outn Pops the top of the stack and outputs it as a number.
16 outa Pops the top of the stack and outputs its ascii value.
17 rol Rotates the stack to the left: [ 7 6 5 ] -> [ 6 5 7 ]
18 swap Swaps the top two values of the stack: [ 7 6 5 ] -> [ 6 7 5 ]
20 mul Pops the top two values from the stack and pushes their product onto the stack.
21 div Pops value A from the stack and then value B. Pushes value B / A onto the stack.
23 pop Pops the top value of the stack
24 gotos Pops the top of the stack and sets the program counter to it (indexed starting at 1).
25 push Pushes the value of the line under this instruction to the stack, skipping that line.
27 ror Rotates the stack to the right: [ 7 6 5 ] -> [ 5 7 6 ]

Examples

Hello world

1234567890123456789012345
123456
1234567890123456789012345
123456
1234567890
1234567890123456789012345
123456
12345678901234567890
123456789012
1234567890123456
1234567890123456789012345
123456
1234567890123456789012345
12345
12345678901234567890
1234567890
1234567890123456789012345
1
12345678901
123456789012
1234567890123456
1234567890123456789012345
1234567
1234567890
123456789012
1234567890123456
123456789012
1234567890123456
1234567890123456789012345
123
1234567890
123456789012
1234567890123456
1234567890123456789012345
12345678901
1234567890123456789012345
1234
12345678901234567890
123456789012
1234567890123456
1234567890123456789012345
123456789012
12345678901
1234567890123456
123456789012
1234567890123456789012345
12345678
1234567890
1234567890123456
123456789012
1234567890123456
1234567890123456789012345
123
1234567890
123456789012
1234567890123456
1234567890123456789012345
123456
12345678901
123456789012
1234567890123456
1234567890123456789012345
12345678
12345678901
1234567890123456
1234567890123456789012345
123
1234567890123456789012345
12345678901
12345678901234567890
1234567890123456

Here's a version which is 42 characters shorter. It uses the lyrics of All Star by Smash Mouth

Truth-machine

123456789
1234567890123456789012345
123456
1234567890123456789012345
12345678
12345678901234567890
12345678901
1234567890123
12345678901234
123456789012345
1234567890123456789012345

123456789012345
12345678901234
123456789012354678901234567890
1234567890123456789012345
1
123456789012345
12345678901234
123456789012345

Computational class

Length is Turing complete since it can interpret brainfuck. The interpreter is being created by User:ChuckEsoteric08 but isn't finished yet.

External resources