$+-?

$+-? is a one dimensional cell-based nearly Turing-complete programming language created by User:TheCanon2.
==Commands==
$+-? has two unbounded registers. $+-? has four commands.
Command	Action
$ 	Go to the other register
+ 	Increment the register
- 	Decrement the register
? 	Skip an instruction if the register != 0
Additionally, $+-? accepts two characters of input at the beginning of every program. 0x0A and the EOF print the register as a Unicode character.
Lowercase letters are used as commands to jump to their uppercase counterparts.
==Examples==
===Hello, World!===
$+++++++++A?b$++++++++$-aB$
$+++C?d$++++++++++$-cD$-
+++++++
+++
$++++++++E?f$--------$-eF$---
------------
$+++++++++G?h$++++++$-gH$+
$++++++I?j$++++$-iJ$
+++
------
--------
$++++++++K?l$--------$-kL$---
===Truth machine===
$++++++F?p$--------$-fP$?z-?nhN$++++++Q?o$++++++++$-qO$+
-$oZ$++++++R?a$++++++++$-rA$H
===Two-Time Cat===
 
$
===XKCD Random Number===
$++++++++++A?b$+++++$-aB$++
===A+B problem===
$------------------------------------------------A?p-$+$aP$
Single-digit addition.
===A-B problem===
S$?p-$-sP++++++Q?e$++++++++$-qE$
Single-digit subtraction.
===Parity calculator===
$?$A?e-?o-aEC?d-cD$?p-$dP+++++++++I?j$++++++++$-iJ$---
$+++++++K?l$+++++++$-kL$
-----------------
+++++++++h
OF?g-fG$?q-$gQ++++++++M?n$++++++++++$-mN$-
$+++R?s$+++++++$-rS$
H
Calculates and prints the parity of single and double-digit numbers.
===Disan Count===
P?e-?o-$+$pE$-$O++++++++++++++++++++++++++++++++++++++++++++++++$-----------------------A?b$
++$-aB
Performs the Disan count for single-digit numbers. By nature of the language, a junk character is printed after every sequence. The first line is too long to be displayed correctly.
===Print the Latin alphabet===
$++++++++A?b$++++++++$-aB+++++++++++++++++++++++++C?d$+
$-cD$+
===Print all of Unicode===
A
+a
===Flip input===
$
$
===Computational class===
$+-? is nearly Turing-complete for it can simulate a two-register Minsky machine.
+ Increment a register
?a- Decrement the register unless it is equal to zero in which jump to A
However, $+-? (in its unmodified form) is not fully Turing-complete for it cannot represent algorithms that require more than 26 distinct jump commands. The interpreter may be modified to allow for diacritics stacking thereby allowing for infinitely many labels.
===Relationship with Brainfuck===
Although $+-? is not a Brainfuck derivative in any meaningful way, its syntax was designed with Brainfuck in mind. As such, it is possible to directly transcribe some Brainfuck programs into $+-?.
< | $
> | $
+ | +
- | -
. | (newline)
[] | A?b(code)aB
==Implementations==
The following Python script is an interpreter.
cell = 0
cells = [0, 0]
program = []
while True:
 line = input('>p ')
 if not line == "eof":
 program.append(line)
 else:
 program.append("")
 break
program = '\n'.join(program)
#Executes the program
Input = input('>i ')
if len(Input) > 0:
 cells[0] = ord(Input[0])
if len(Input) > 1:
 cells[1] = ord(Input[1])
inst = 0
while inst < len(program):
 if program[inst] == "$":
 cell = (cell + 1) % 2
 elif program[inst] == "+":
 cells[cell] += 1
 elif program[inst] == "-":
 cells[cell] -= 1
 elif program[inst] == "?":
 if cells[cell] != 0:
 inst += 1
 elif program[inst] == "\n":
 print(chr(cells[cell]), end="")
 elif ord(program[inst]) >= 97 and ord(program[inst]) <= 122:
 inst = program.index(chr(ord(program[inst])-32))
 else: pass
 inst += 1
The interpreter uses the symbol eof to mark the end of the program.
Category:Languages
Category:Cell-based
Category:Turing complete
Category:Implemented
Category:2024