Elog
Logic circuits written as a stack program. Bits go in, bits come out, and nothing loops.
Aptennap, 2011 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 9 known programs · Test method
Run it
The idea
Aptennap made Elog in 2011 to model logical circuits. A program takes a string of bits such as 10101 and gives back another one. Any character that is not a command is a variable, and the variables take the input bits in the order they first appear in the program. There are no loops, so every program stops. The gates are functionally complete, so any combinational circuit can be written.
The machine
| Char | Does |
|---|---|
' | NOT |
& \| ^ | AND, OR, XOR of the top two bits |
. | Duplicate the top bit |
0 1 | Push the bit |
| a variable | Push its bit |
:x | Pop a bit into the variable x |
; | End, and print the variables and bits after it |
Example
The doubler takes 3 bits and prints them with a 0 after, which is the number times 2.
The doubler takes 3 bits and prints them with a 0 after, which is the number times 2.
The multiplexer names a, b and s first so that they take the input bits in that order. Then it prints a when s is 0 and b when s is 1.
The prime test reads 4 bits, the first one highest, and keeps its answer in z. On 7 it prints 1.
The rules give this program 0 for 2 and 1 for 10. Its second term, ab'c, takes in 10 and 11; the term for 2 and 3 would be a'b'c.
Patterns it teaches
- Stack machines: a circuit written in postfix.
Further
See also
Stack-based
Write your own in Run Convert a program from Elog
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: elog.
Command line
shib run elog -e 'abc;abc0' --input '101'shib manual elogSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/elog.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org