Fluid

From Esolang
Jump to navigation Jump to search

Fluid is an esolang devised by User:Yayimhere, in a few minutes, after reading the esolang article on BIX Queue Subset's. It is the BIX queue subset cffda cttda d. Note that the c is skipped if not in idle mode.

A non BIX definition

Fluid has a queue of bits. It also has a boolean register, that can have the values 1, 0, and NaB, where NaB stands for "Not a Bool"; Its default value is NaB. Below is its command set:

  • n: set the boolean register to NaB.
  • 1: set the boolean register to 1, if an only if it is NaB, then check if the boolean register is 1; if true enqueue a 1 twice, else do nothing; set the boolean register to NaB, and then shift a value of the queue, then set the boolean register to that value.
  • 0: does the exact same process as 1, however enqueue a 0.

Note that the queue never will have a NaB in it.

The data queue can be defined, by having a list of bits. Then a space and the command list. The list of bits is read left to right, so the leftmost bit is at the front of the queue. We loop over the entire program again and again until it halts

Implementations

Python:

#initialise
program=input("program(no data string):\n")
data=input("datastring:\n").split()
bool_register=2
length=len(program)
index=0

#enter program loop
while True:
    if program[index] == "1":
        if bool_register == 2: 
            bool_register=1
        if bool_register == 1: 
            data.append("1")
            data.append("1")
        try:
            bool_register=int(data.pop(0))
        except:
            break
        print("".join(data)+"\n")
    if program[index] == "0":
        if bool_register == 2: 
           bool_register=1
        if bool_register == 1: 
            data.append("0")
            data.append("0")
        try:
            bool_register=int(data.pop(0))
        except:
            break
        print("".join(data)+"\n")
    if program[index] == "n":
        bool_register=2
    index+=1
    if index>length-1:
        index=0