Afstal

From Esolang
Jump to navigation Jump to search

Afstal is a string algorithm, which is similar to Tag system but has some differences. It is by User:Cycwin conceived.

Definitions

Given an initial string, traversing from front to back in character units,

  1. If a number (0-9) is encountered, let this number be n (n is the units digit), copy the first n characters of the initial string to the end of the string, delete the first n+1 characters, and start the traversal again.
  2. If the symbol & is encountered, the last two characters of the current string are copied to the beginning and then the traversal starts from the beginning.

Examples

Infinity Loop:

&a

Interpreter

There is an interpreter in python3.

k="pqp2ahi1ah1aaa&1" #your code goes here.
c=0
r=0
while c<len(k) and r<100:
    if k[c] in "0123456789":
        k += k[:int(k[c])]
        k = k[int(k[c])+1:]
        print(k,"number")
        c = -1
    elif k[c]=="&":
        k = k[-2:] + k 
        print(k,"symbol")
        c = -1
    print(k,"final")    
    r += 1
    c += 1
if r == 100:
    print("Exceeded the threshold.")    

Computational Class

In fact, I can't prove that it's turing completeness, it can't simply simulate BCT or pure Tag system. I hope someone can help me. (Please delete this text when writing.)


Wishing everyone a happy life every day!