esolang

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

Expected: 1

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

PartIs
b,jFlip 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 0Random before each instruction
Cells 1 and upShown 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!.

Expected: 100100011001011101100110110011011110100000111011111011111110010110110011001000100001

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

Further

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 flij

Source

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