+++

From Esolang
Jump to navigation Jump to search

made by Fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff (talk) 02:45, 25 September 2024 (UTC)

Caption text
Command What it do?
+[increment] accumulator += increment
++ accumulator++
! print accumulator
? input accumulator
!$ print accumulator as char
?$ input accumulator as char
[number] accumulator = number
$ clear input buffer
+? add user input

Programs

Hello, World!

72 !$ 101 !$ +7 !$ !$ +3 !$ 44 !$ 32 !$ 87 !$ 111 !$ 114 !$ 108 !$ +-8 !$ 33 !$

A+B Problem

? +? !

Numerical Cat

? !

One Time Cat

?$ !$ $

+ compiled into +++

def convert(c): return(c.count("+")*"++ ")

Interpreter

def plus(code,a=0,ib=[]):
    def isInt(x):
        try: int(x); return True
        except: return False
    for i in code.split(' '):
        if i == "": pass;
        elif i == '+?':
            if isInt(query := input()): a += int(query)
            else: print('Invalid Number');return
        elif i[0] == '+':
            if i == '++': a+=1
            elif isInt(i[1:]): a+=int(i[1:])
            else: print(f'Invalid command: {i}'); return
        elif isInt(i): a=int(i)
        elif i == '?':
            INP = input()
            if isInt(INP): a=int(INP)
            else: print(f'Invalid Input'); return
        elif i == '?$':
            if ib == []: ib+=list(input())
            else: a = ord(ib.pop(0))
        elif i == '!': print(a)
        elif i == '$': ib = []
        elif i == '!$':
            if a >= 0: print(end=chr(a))
            else: print(f'Invalid Character'); return
        else: print(f'Invalid command: {i}'); return
    return (a,ib)
def shell():
    a=0;ib=[]
    while (code:=input('>>> '))!='END':
        if code == '': continue
        F = plus(code,a,ib)
        if F==None:return
        a = F[0]; ib = F[1]
        print('')
shell()