Bitwise Cyclic Tack

From Esolang
Jump to navigation Jump to search

Bitwise Cyclic Tack (BCTk) is an esolang invented by User:None1. It is a derivative of BCT where the data-string is operated like a stack instead of a queue.

Commands

Command Execution
0 Delete the rightmost data-bit.
1 Goto the next command (say x). If the rightmost data-bit is 1, copy x to the right end of the data-string.

Example

Program: 00111
Initial Data-string: 101
System evolution:
Commands    Data-
Executed    String
--------    -------
    0       101
    0       10
   11       1
   10       11
    0       110
   11       11
   10       111
    0       1110
   11       111
   10       1111
    0       11110
   11       1111
  ...

This program goes on forever appending 1's.

Interpreters

Python

from time import sleep


class CyclicList(list):
    def __getitem__(self, x):
        return super().__getitem__(x % self.__len__())


code = CyclicList(map(int, input("Code: ")))
data = list(map(int, input("Data-string: ")))
ip = 0
while 1:
    print(f'IP: {ip%len(code)}\t Data-string: {"".join(map(str,data))}')
    if not code or not data:
        print("Halt!")
        break
    op = code[ip]
    if op:
        if data[-1]:
            data.append(code[ip + 1])
        ip += 2
    else:
        data.pop()
        ip += 1
    sleep(0.2)

Computational class

Unknown, probably a PDA.