Flij
One instruction. Flip a bit, and if it was 1, jump.
Turing complete: no · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Flij lives on a tape of bits numbered by every integer. Its name is its only instruction, FLip If was 1 Jump. An instruction bit,jump flips one bit, and if that bit was 1 before the flip, the program goes on at instruction jump. Otherwise it goes on to the next one, and it stops when it runs past the end.
Read the story
There is no input or output command. The cells below 0 are inputs, which the user may flip; in this implementation the input sets them before the run. Every cell is an output, since the user may look at any of them at any time. Cell 0 is random before every instruction, which gives the language its only source of chance.
The machine
| Part | Is |
|---|---|
b,j | Flip bit b; if it was 1, go to instruction j |
; | Splits instructions, numbered from 0 |
| Cells -1, -2, ... | Inputs, here the characters 0 and 1 in order |
| Cell 0 | Random before each instruction |
| Cells 1 and up | Shown at the end, up to the highest cell the program names |
b,k as instruction k sets bit b to 1. If the bit was 0 it flips, and if it was 1 it flips to 0 and jumps back to itself to flip again. A program names a fixed set of cells, so it is a finite state machine.
Example
The truth machine copies cell -1 to cell 1.
The truth machine copies cell -1 to cell 1.
The Hello world sets 46 bits. Read 7 cells at a time, cells 1 to 84 spell Hello world!.
The AND gate, 1,0;-1,2;-2,3;-1,7;-2,7;-1,5;-1,8;1,7, gives 1 on all four inputs. Its last instruction is meant to clear cell 1, but jumping back to itself sets it again.
Patterns it teaches
- One instruction: a conditional flip is the whole language.
Further
See also
OISC
Cell-based
Write your own in Run Convert a program from Flij
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: flij.
Command line
shib run flij -e '-1,2;-1,3;1,3' --input '1'shib manual flijSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/flij.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org