Gbagbo
Every value is a bag of bags. Text is a chain of bags, one bit deep each.
2016 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Gbagbo calculates with bags. A bag is a set that also counts how many times each element is in it, and its elements are bags again. The only bag to start from is the empty one, []. The language is named after Laurent Gbagbo, the former president of Ivory Coast.
Read the story
A program is a list of functions. There is no if and no number. Union, intersection and difference combine two bags count by count, and a star before an argument runs a function once for every element of a bag and adds up the results.
The machine
| Code | Does |
|---|---|
f x y = expr. | Declare a function with its parameters |
[a 2×b] | A bag that holds a once and b twice |
∪ \| | Union, the larger count of each element |
∩ & | Intersection, the smaller count |
△ ⊖ ^ | Difference, the distance between the two counts |
f *x | Run f on each element of x and add the results |
== | A comment to the end of the line |
The operators have equal precedence and group from the left. Input and output are bits. The empty bag is the end, [rest] is a 0 bit and [[] rest] is a 1 bit, each byte highest bit first. The first function runs, with the input as its argument.
Example
The cat gives its input back unchanged.
The cat gives its input back unchanged.
The Hello world declares two functions named 0 and 1. 0 x puts a 0 bit in front of x and 1 x a 1 bit, so the program reads as the 104 bits of the text.
Patterns it teaches
- Encoding tricks: bits as bags nested one inside the other.
Further
See also
Also in Functional and concatenative
Write your own in Run Convert a program from Gbagbo
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: gbagbo.
Command line
shib run gbagbo -e 'cat x = x.' --input 'cat'shib manual gbagboSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/gbagbo.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org