Output

From Esolang
Jump to navigation Jump to search

Output is an esolang invented by User:None1.

Commands

Input

Reads a line of input

Output value

This can output a string if the value is surrounded by quotes (""), but there also two special values without quotes:

the input

is the result of the last input command, if no input command is executed before, do nothing.

the program's source code

is the program's source code.

This command does not output any line feed or space after outputing value.

Other values raise a syntax error, but an incorrect command is ignored.

It is case sensitive, and first letter of each line must be capitalized.

Examples

Hello World

Output "Hello World!"

Cat program

Input
Output the input

Cheating quine

Output the program's source code

Syntax error

Output 1

n^2 by Infinitehexagon (TIO)

Output the program's source code   
Output the program's source code
Output the program's source code

n = the amount of "Output the program's source code" lines
For some reason TIO squares the amount of "Output the program's source code"'s in the interpreter, thus making an n^2 program

Interpreter

Python

inp=''
lines=[]
def execute(c):
    global inp
    c=c.strip()
    if c=='Input':
        inp=input()
    elif c.startswith('Output '):
        val=c[7:].strip()
        if val=='the input':
            print(inp,end='')
        elif val=="the program's source code":
            print('\n'.join(lines),end='')
        elif val[0]=='"' and val[-1]=='"':
            print(val[1:-1],end='')
        else:
            raise SyntaxError('Unrecognized value format')
while 1:
    try:
        x=input()
    except:
        break
    else:
        lines.append(x)
for i in lines:
    execute(i)

Try it online! (Use a line with only one character "!" to separate program and input if there is input)

See also

  • Op, a shorter version of Output.
  • OutputF, a superset of Output.