hexad

From Esolang
Jump to navigation Jump to search

hexad is an esolang designed and published by User:Yayimhere, to be unreliable when trying to store and modify data. it is as such propably not Turing complete, however Yayimhere would be interested in a counter proof of such. hexad uses sextuplets of commands, and as such, it is called hexad.

Syntax

Every command in hexad is a single character, however each program is put into divisions of sextuplets, as mentioned before. If the program cannot properly be divided into sextuplets, the program goes into Undefined behaviour(ie. dont do that).

Commands

hexad uses the below commands, all of which affect the program. for these definitions, the sextuplet a specific command is located in is called the local sextuplet:
.

Within a sextuplet, this is considered "unfilled space", so it functionally is a NOP.

f

Locate any unfilled commands within the local sextuplet. Then for any unfilled command with index x, find the command with the same index x in the following sextuplet, and replace the unfilled command with that, then do that for the whole local sextuplet.

d

Deletes the last command of the local sextuplet. This will cause "flow" from other sextuplets into this one, which as such requires a . be added to the end of the program(and this command does that).

=

Moves the local sextuplet to the end of the command list, without copying it.

c

Copies the sextuplet following the local one to the end of the command list.

_

Add an f to the end of the program, and then next add the local sextuplet, with the first command removed(which preserves the sextuplet division).

Examples

Sextuplet looping counter:

c.....c.....

Implementations

An (untested) python interpreter:

program=input("program:\n")
def questionmark (string1,string2):
    i = -1
    res = string1
    while i<len(string1):
        if string1[i]==".":
            res[i]=string2[i]
        else:
            #do nothing
    return res

def interpret (prog):
    ind1=-1
    ind2=-1
    current=""
    p=[prog[i:i+6] for i in range(0, len(prog), 6)]
    while ind1*6-6+ind2 != len("".join(p))-1:
        ind1+=1
        if ind2<5:ind+=1; else:ind2=-1
        current=(p[ind1])[ind2]
        if current==".": #NOP
        if current=="d": p[ind1]=current[:-1]; p=[("".join(p)+".")[i:i+6] for i in range(0, len(("".join(p)+".")), 6)]
        if current=="=": p+=pop(p[ind1])
        if current=="c": p+=p[ind1+1]
        if current=="_": p+="?"+(p[ind1+1])[1:]
        if current=="?": p[ind1]=questionmark(p[ind1],p[ind1+1])
        print(p[ind1] + "," + p[ind1+1])
intepret(program)