Txet

From Esolang
Jump to navigation Jump to search
Not to be confused with Text, nor txeT.

Txet is a programming language that was made by User:Fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and has 2 forms of memory, a 1d tape where each cell has a one-character name, and an accumulator. Each command is 2 letters long. The first character says what to do and the second says what cell to do it on.

Commands

Commands
Command Description
+ append accumulator to the end of selected cell
p switch accumulator and selected cell
` print selected cell
d set selected cell to its name
% replace "%" with accumulator in selected cell and vice versa
> move forward by the 1st character in selected cell's unicode id
< move backward by the 1st character in selected cell's unicode id
i set selected cell to input
q if selected cell is its name, skip next command
- remove first character of selected cell
r take 1st character of selected cell and put it at the end
0 set selected cell to ""

Duplicating values

To duplicate the value in X into Y, use this code:

pX0Y+YpX

Programs

Hello, World!

dHpH+Pdepe+Pdlpl+P+Pdopo+Pd,p,+Pd p +PdWpW+Pdopo+Pdrpr+Pdlpl+Pddpd+Pd!p!+P`P

Truth-machine

i1d\5q1>\5d0`0d\3<\3d1`1d\3<\3

Cat program

iඞ`ඞ

interpreter

def swap(text,toSwap):
	_T = list(text); c = 0; __T = _T
	while c < len(_T):
		if _T[c] == "%":
			_T[c] = toSwap #done!
		elif ("".join(_T))[c:(c+len(toSwap))] == toSwap:
			_T[c:(c+len(toSwap))] = '%'
		c+=1
	_T = "".join(_T)
	return _T
def prepare(L,LN,NL):
	if not(NL in LN):
		LN.append(NL)
		L.append("")
	return [L,LN]
def compute(code):
	i=0; A=""; tape=[]; tapeN=[]
	while i<len(code):
		__=prepare(tape,tapeN,code[i+1]); tape=__[0]; tapeN=__[1]
		if code[i] == "+":
			tape[tapeN.index(code[i+1])] += A
		elif code[i] == "p":
			__=A; A=tape[tapeN.index(code[i+1])]; tape[tapeN.index(code[i+1])]=__
		elif code[i] == "`":
			print(tape[tapeN.index(code[i+1])],end="")
		elif code[i] == "d":
			tape[tapeN.index(code[i+1])] = code[i+1]
		elif code[i] == "%":
			tape[tapeN.index(code[i+1])] = swap(tape[tapeN.index(code[i+1])],A)
		elif code[i] == ">":
			try:
				i += ord(tape[tapeN.index(code[i+1])][0]) * 2
			except IndexError:
				pass
		elif code[i] == "<":
			try:
				i -= (ord(tape[tapeN.index(code[i+1])][0])) * 2 + 2
			except IndexError:
				pass
		elif code[i] == "i":
			tape[tapeN.index(code[i+1])] = input()
		elif code[i] == "q":
			if tape[tapeN.index(code[i+1])] == code[i+1]:
				i+=2
		elif code[i] == "-":
			try:
				tape[tapeN.index(code[i+1])] = tape[tapeN.index(code[i+1])][1:]
			except IndexError:
				pass
		elif code[i] == "r":
			try:
				tape[tapeN.index(code[i+1])] = tape[tapeN.index(code[i+1])][1:] + tape[tapeN.index(code[i+1])][0]
			except IndexError:
				pass
		elif code[i] == "0":
			try:
				tape[tapeN.index(code[i+1])] = ""
			except IndexError:
				pass
		i+=2
	print("")
def start():
    Import = input("Import a file?")
    if Import == "yes":
        Import = input("Please input file path:\n")
        Import = open(Import,encoding='utf-8')
        Import = Import.read()
    else:
        c = " "
        Import = ""
        while c != "":
            c = input()
            Import = Import + c + "\n"
    compute(Import)
start()
input()