We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

+*-

From Esolang
Jump to navigation Jump to search

+*- (say "add star minus") is an esolang very close to a Minsky machine, it is created by User:None1.

Commands

It had two unbounded accumulators named a and b, both set to zero at start of program.

Command Meaning
+ Increment a
* Swap a and b.
- If a is 0, jump to the start of program, otherwise, decrement a.

Examples

Infinite loop

-

Computational class

This language is not Turing-complete: if both counters A and B are greater than the length of the program, the program reaches the end and halts. As such, it can be emulated using a finite-state machine plus one counter (the finite state remembers which of the counters is less than the length of the program and what its value is, and uses the counter to remember the value of the other counter); a finite-state machine plus one counter is not Turing-complete, and because it can emulate +*-, +*- must not be Turing-complete either. Proof by User:ais523.

See Also

Implementations

Lua

s=io.read()a=0 b=0::e::for c in s:gmatch"."do if c==("-"):sub(a+1)then goto e end a,b=c=="+"and a+1 or(c=="*"and b or a-1),c=="*"and a or b end

Python interpreter with a debug command

c=input();p=a=b=0
while p<len(c):
 if c[p]=="+":a+=1
 elif c[p]=="*":a,b=b,a
 elif c[p]=="-":
  if a:a+=-1
  else:p=0
 elif c[p]=="d":print(a,b)
 p+=1