SETANDCOUNT
Introduction & Syntax
SETANDCOUNT (SAC for short) is a language for storing in an ordered list.There is SAC syntax:
- Numbers
1~6
:Suppose that the first n values are added by one to form S(n),O(S(n)) represents the original value of the number of operations currently performed. The numbers 1-6 represent S(1)~S(6).When O(S(n)) (n represents any number from 1 to 6) is a non-positive number,The running result is equivalent to S(n+(-O(S(n))).
Tip: When the number in S() is greater than the number of elements in the list, there is an extra 1 in the last list.
- Number
0
:Jump to the position item of the number following 0 and set this item to the opposite of the second number following 0.
- Number
9
:If the list does not shrink before the instruction, the code jumps to the number represented by the number between the 9 and the first 0 after the 9.
- Number
7
and Number8
:Input and Output.Store to the first unit. (stored in digital form)
I don't think the operation when the item is equal to 0 is really useful, so I may update its usage later.
Some examples
Calculation 8-2+1:
11111122329110
infinite loop:
910
Cat program:
78
Truth machine(Input 0 or 1 => 1 or 2)(and if you input 2 it will puts 3):
7218940
Interpreter
The interpreter written in Python follows.
l=[];pointer=0;cd="7218940";cp=0;c=1#The content of the variable cd is the code while cp<len(cd): i=cd[cp];o=l[:] if i in "123456": f=[] t=(int(i),0) if int(i)<=len(l) else (len(l),1) for k in range(t[0]): if l[k]>0:l[k]+=1 elif l[k]<0:f.append(str(-l[k])) if t[1]:l.append(1) if len(f)>0:cd="".join(list(cd[:cp])+f+list(cd[cp:])) pointer=0;l=list(set(l)) l.sort() if len(o)>len(l):c=0 if i=="0": pointer=int(cd[cp+1]);l[pointer]=-int(cd[cp+2]) cp+=2 l.sort() if len(o)>len(l):c=0 if i=="9": tmp=cp+cd[cp:].index("0") if c:cp=int(cd[cp+1:cp+cd[cp:].index("0")])-2 else:cp=tmp;c=1 if i=="7": if len(l)>0:l[0]=ord(input()[0]) else:l.append(ord(input()[0])) if i=="8": print(chr(l[-1])) cp+=1 #print(l)
Something I wanted to say
This esolang is inspired by Python's set type. It's stored roughly as a set in Python. However, sometimes you can't sort in the correct order. (For example, {7,8,9} will be converted to {8,9,7} and so on) .so I'm abandoning the set and using an ordered list store.It's a completely helpless move.
Good Luck.