SOAP

From Esolang
Jump to navigation Jump to search

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),etc.} 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 variable number that can be used as a kind of pointer to the set.

Instructions

*(integer) - flip membership
"(character) - print character to the console
∪(set) - store the union of the main set and the set literal
∩(set) - store the intersection of the main set and the set literal
⊆(set)[ - start looping as long as the set is a subset of the literal
⊂(set)[ - start looping as long as the set is a proper subset of the literal
⊄(set)[ - start looping as long as the set is not a subset of the literal
⊇(set)[ - start looping as long as the set is a superset of the literal
⊃(set)[ - start looping as long as the set is a proper superset of the literal
⊅(set)[ - start looping as long as the set is not a superset of the literal
=(set)[ - start looping as long as the set is equal to the set literal
] - end loop
c - store the complement of the main set
-(set) - store the difference of the main set and the set literal
_(set) - store the difference of the set literal and the main set
: - increment %
; - decrement %
~ - accept input into the current character
'(character)/(code)\ - runs the code only if the character matches the current 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]\