S₅
Eight words, every one a form of "set", over ordered sets of sets.
Gribnit, 2026 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Gribnit made S₅ in 2026. Every token is a form of the word set, and all data are ordered sets of sets. There are no numbers in memory. A set has a value instead. Read its elements from left to right starting at 0; an empty element adds 1 and any other element doubles. So {∅, {∅}, ∅} is 3, and 42 takes eight elements.
Read the story
The same rule turns words into integers. set adds 1 and sets doubles, so set sets set is 3. The only branch is a call that runs when a set is not empty, and the only loop is a call. The specification shows it is Turing complete with a Bitwise Cyclic Tag interpreter.
The machine
The universe U starts as {∅} and the cache C starts unbound. An instruction is Set, an opcode and its addresses.
| Words | Does |
|---|---|
Set sets A B set D | D = A ∪ B, the elements of both in order |
Set Set's A B set D | D = the elements of A that appear in B |
Set set A B set D | D = the elements of A that do not appear in B |
Set Sets set sets' N | C = C[N] |
Set Sets' A | Call the subroutine in A, or in C |
Set Sets' set X A | Call it only when X is not empty |
Sets' Sets' A ... Sets' | Define a subroutine and store it in A, or in C |
| Address | Is |
|---|---|
Set's sets Set's set | U and C |
Sets sets sets' N Sets set sets' N | U[N] and C[N] |
Sets sets' A | {A}, the set that holds A |
set's' | A number line in, a number line out |
sets set's' | One byte in, the value as bytes out |
An address may end in sets' N, which reads the value N more times as an index into U. The run halts as soon as U is empty. A byte 0 reads as {{∅}}, which is not empty, so only the end of input reads as ∅.
This implementation leaves out the .s5b binary I/O, whose token codes the specification does not give.
Example
The first prints the value of U ∪ U, which is {∅, ∅}.
The first prints the value of U ∪ U, which is {∅, ∅}. The second reads 42 as the set {∅, {∅}, {∅}, ∅, {∅}, {∅}, ∅, {∅}}, takes away the elements of U[0], which is ∅ and has none, and prints the value.
The cat stores two subroutines at U[1] and U[2]. The first reads a byte into C and calls the second when C is not empty; the second writes C and calls the first. Each call ends its body, so it takes that body's place and the loop runs in constant space.
Patterns it teaches
- Turing tarpit: three set operations and a conditional call.
- Encoding tricks: a number is the shape of a set.
- Code as data: a subroutine is a set of lines, stored and indexed like any other set.
Further
See also
Tree-based
Generated by AI
Write your own in Run Convert a program from S₅
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: s5.
Command line
shib run s5 -e 'Set sets Set'\''s sets Set'\''s sets set set'\''s'\'''shib manual s5Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/s5.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org