PlusOrOutput

From Esolang
Jump to navigation Jump to search

PlusOrOutput is an esolang create by User:None1 and inspired by PlusOrMinus.

Commands

It has only 2 commands:

+: Increments the accumulator.

.: Outputs the accumulator as ASCII.

It works on a wrapping 8-bit accumulator.

Examples

Hello World

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.

Nope. interpreter

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++.+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.

PlusIntOutput

Just like PlusOrMinus, PlusOrOutput has a variation: PlusIntOutput,where the integer is added if there is an integer after the current +, otherwise still add 1.

Examples

Hello World

+72.+29.+7..+++.+177.+55.+24.+++.+250.+248.+189.

Nope. interpreter

+78.+33.+.+245.+201.

Interpreter for PlusOrOutput only (in Python)

c=input()
x=0
for i in c:
    if i=='+':
        x=(x+1)%256
    if i=='.':
        print(chr(x),end='')

Interpreters for both languages in JavaScript

online interpretation

function plusoroutput(program){
    var output='',x=0;
    for(let i of program){
        if(i=='+'){
            x++;if(x==256){x=0}
        }else if(i=='.'){
            output+=String.fromCharCode(x);
        }
    }
    return output;
}

online interpretation

function plusintoutput(program){
    var x=0,output='';
    while(program.length){
        if(program[0]=='+'){
            var a=0;
            program=program.slice(1);
            if(!'0123456789'.includes(program[0])){
                x=(x+1)%256;
            }else{
                while('0123456789'.includes(program[0])){
                    a=a*10+program.charCodeAt(0)-48;
                    program=program.slice(1);
                }
                x=(x+a)%256;
            }
        }else if(program[0]=='.'){
            output+=String.fromCharCode(x);
            program=program.slice(1);
        }else{
            program=program.slice(1);
        }
    }
    return output;
}