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 Adds the top two values on the stack and pushes the result onto the stack.
11 sub Subtracts the top two values on the stack and pushes the result onto the stack.
12 dup Duplicates the top value of the stack.
13 cond If the top value of the stack is 0, skip the next instruction. Then pop it.
14 gotou Sets the program counter to the value of the line under the instruction.
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.
20 mul Multiplies the top two values on the stack and pushes the result onto the stack.
21 div Divides the top two values on the stack and pushes the result onto the stack.
24 gotos Sets the program counter to the value on top of the stack
25 push Pushes the value of the line under this instruction to the stack.

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

External resources