SOAP
No stack, no tape, no accumulator. One set of numbers, and loops that ask whether it is a subset.
BoundedBeans, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
BoundedBeans made SOAP, Set Oriented Arithmetic Programming, in 2022. Most esolangs keep their data on a stack, a queue or a tape. SOAP keeps one set of whole numbers from 1 up. A set has no order and no index, so a program reads it by asking whether a number is in it.
Read the story
Numbers are written in base 3, which the specification says is there to be a bit annoying. {12,122,21112,21120} is the set of 5, 17, 203 and 204. The only other piece of memory is the variable %, a number that works as a pointer into the set.
The machine
| Command | Does |
|---|---|
*n | Flip whether n is in the set |
"c | Print the character c |
∪ ∩ - _ and a set | Union, intersection, the set minus it, or it minus the set |
c | Take the complement |
⊆ ⊂ ⊄ ⊇ ⊃ ⊅ = and a set, then [...] | Loop as long as the test holds |
: ; | Add 1 to %, or take 1 |
~ | Read a character |
'c/...\ | Run once if the last character read is c |
A set is written {n,n,...} or Ø, and a number in it may be %. The complement of a finite set is infinite, so this implementation keeps the set as a finite list and a flag that says whether it means the numbers in the list or every number but those.
SOAPI is the variant in plain bytes. It writes ∪ ∩ ⊆ ⊂ ⊄ ⊇ ⊃ ⊅ Ø as U I s p n S P N E and allows comments, and both spellings work. The specification shows that SOAP is Turing complete by turning BitChanger into it. } becomes *%:, < becomes ; and [ becomes ⊇{%}[.
Example
The loop prints Ha while % is in the set {1, 2, 3}, made by *1*2*10.
The loop prints Ha while % is in the set {1, 2, 3}, made by *1*2*10. The specification does not say where % starts; it has to be 1 for three Ha.
The truth machine. *1 puts 1 in the set, so on a 1 the loop ⊇{1} never ends. On a 0 it prints 0 once.
The cat has a line 'c/"c\ for each of 191 characters, 32 to 126 and 160 to 255, inside a loop that runs forever.
Patterns it teaches
- Turing completeness: by turning BitChanger's bits into members of the set and its pointer into
%.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from SOAP
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: soap.
Command line
shib run soap -e '*1*2*10
⊇{%}["H"a :]'shib manual soapSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/soap.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org