SOAP
SOAP (the name standing for Set Oriented Arithmetic Programming) is an esolang by User:BoundedBeans. Many esolangs use stacks, queues, tapes, or accumulators to store data, but not many have done sets.
Storage
SOAP has one single set of natural numbers, excluding zero. Since sets cannot be indexed, it is tricky to actually access the data, but it can be done by checking membership of a specific item, which can be treated as a boolean.
Literals
In order to check for membership, we need a way to represent integers. This is done in base 3 (ternary), just to be a bit annoying. Set literals are the only literal ever used alone, done with {(integer),(integer),…}
with integer literals. For example, a set containing 5, 17, 203, and 204 would be {12,122,21112,21120}
. Set literals are used for checking things like subsets. The empty set can be written with Ø
, though it doesn't have a ton of use. Integers can also be represented with %
, which is a variable number that can be used as a kind of pointer to the set.
Instructions
Command | Description |
---|---|
*integer
|
Flip the membership of the integer in the main set
|
"character
|
Print the character to the console
|
∪set
|
Store the union of the main set and the specified set in the main set
|
∩set
|
Store the intersection of the main set and the specified set in the main set
|
-set
|
Store the difference of the main set and the specified set in the main set
|
_set
|
Store the difference of the specified set and the main set in the main set
|
c
|
Replace the main set by its complement |
⊆set[instructions]
|
Execute the instructions as long as the main set is a subset of the specified set
|
⊂set[instructions]
|
Execute the instructions as long as the main set is a proper subset of the specified set
|
⊄set[instructions]
|
Execute the instructions as long as the main set is not a subset of the specified set
|
⊇set[instructions]
|
Execute the instructions as long as the main set is a super of the specified set
|
⊃set[instructions]
|
Execute the instructions as long as the main set is a proper superset of the specified set
|
⊅set[instructions]
|
Execute the instructions as long as the main set is not a superset of the specified set
|
=set[instructions]
|
Execute the instructions as long as the main set is equal to the specified set
|
:
|
Increment the variable % by one
|
;
|
Decrement the variable % by one
|
~
|
Accept a character input and store it in the current character |
'character/code\
|
Execute the code once if the last user input character equals the specified character
|
Computational class
BitChanger can be trivially substituted into this language, making it Turing-complete.
} - *%: < - ; [ - ⊇{%}[ ] - ]
This kind of misses the point of the language, though.
Examples
Hello world
"H"e"l"l"o"," "W"o"r"l"d"!
Truth-machine
*1~'0/"0\'1/⊇{1}["1]\
Cat program
This infinitely repeating cat program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'Â/"Â\ 'Ã/"Ã\ 'Ä/"Ä\ 'Å/"Å\ 'Æ/"Æ\ 'Ç/"Ç\ 'È/"È\ 'É/"É\ 'Ê/"Ê\ 'Ë/"Ë\ 'Ì/"Ì\ 'Í/"Í\ 'Î/"Î\ 'Ï/"Ï\ 'Ð/"Ð\ 'Ñ/"Ñ\ 'Ò/"Ò\ 'Ó/"Ó\ 'Ô/"Ô\ 'Õ/"Õ\ 'Ö/"Ö\ '×/"×\ 'Ø/"Ø\ 'Ù/"Ù\ 'Ú/"Ú\ 'Û/"Û\ 'Ü/"Ü\ 'Ý/"Ý\ 'Þ/"Þ\ 'ß/"ß\ 'à/"à\ 'á/"á\ 'â/"â\ 'ã/"ã\ 'ä/"ä\ 'å/"å\ 'æ/"æ\ 'ç/"ç\ 'è/"è\ 'é/"é\ 'ê/"ê\ 'ë/"ë\ 'ì/"ì\ 'í/"í\ 'î/"î\ 'ï/"ï\ 'ð/"ð\ 'ñ/"ñ\ 'ò/"ò\ 'ó/"ó\ 'ô/"ô\ 'õ/"õ\ 'ö/"ö\ '÷/"÷\ 'ø/"ø\ 'ù/"ù\ 'ú/"ú\ 'û/"û\ 'ü/"ü\ 'ý/"ý\ 'þ/"þ\ 'ÿ/"ÿ\ ]
Interpreter
- Common Lisp implementation of the SOAP programming language. Please note that the concrete character set deployed constitutes a dependency on the Common Lisp implementation; in corollary, Unicode support may or may not be a feature incorporated in the personal environment. The interpreter at hand has been developed and tested with Steel Bank Common Lisp (SBCL) version 1.1.4 as part of the Lisp Cabinet 0.3.5 bundle.
- Copy of the above Common Lisp implementation with a few changes:
- Merged into one file to be run on tio.run
- Fixed some bugs (the % variable and decrementation now work)
- SOAP programs now have to make their own prompts
- Keep in mind that I (User:BoundedBeans) really don't know Common Lisp at all and the style might be bad.
To run both Common Lisp implementations:
- Escape quotes and backslashes in your program (Do not escape newlines).
- Add
(interpret-SOAP "your code")
to the end of main.lisp - If running in the first implementation:
- You probably want to empty tests.lisp
- You can't use the variable due to a bug (and if you could,
;
would increment it like:
)