Onechar

From Esolang
Jump to navigation Jump to search

Simple Introduction

Onechar(onch for short) is a esolang. It was inspired by a sentence in TypeInt. Its code can be a number or any character string. If it is a character string, the length of the character string will be used as the code.

The Syntax

First we generate a list. The content of the list is the code (hereinafter referred to as N), which is the result of dividing N by 2 and rounding down. The result of dividing N by 3 and rounding down... that is, all odd numbers starting with 3 after the first item is 1 and 2. The list stops building after the 1 occurs. A queue of two values for each item is then generated, and the queue initially has an item with a value of 0 and a value of 1.


It then begins to traverse each item (the value of each item is hereinafter referred to as k). The result of dividing k by 2, 3, 4, 5, 7, and 9 respectively determines the operation.


If the second value of the top value in the queue equals 2, let k plus the first value of the top value. If k mods 4 is 0 or 2 we have operations below:

  • If k mods 5 is 0, let p be the place in the list of k(p is a number), let k be the no.p-2(if p-2 < 0, we will use 0) term in the list.
  • If k mods 5 is 1 do the operations up but replace 2 to 1.
  • If k mods 5 is 2 if the top of queue is less than or equals 0, use next k and back to the place where begin.
  • If k mods 5 is 3, swap the top of queue and the bottom of the queue.
  • If k mods 5 is 4, swap 2 terms on the top of queue.

If k mods 3 greater than 0, add a term in the queue whose first value is k mods 7 and second value is k mods 3. If k mods 9 is 1, let the top of queue's first value round k mods 7. If k mods 9 is 2, let i be the first value of the top of the queue, if i is 0 let i be 1, let i be 0 if not that. If k mods 9 is 3, delete the bottom of the queue. If k mods 9 is 4, if i mods 2 is 1, output the first value of the top of queue; if i mods 2 is 0, let the first value of the top of the queue be the input character's place in the ASCII.

Some simple programs(?)

this program exactly can output 5 but it will into dead repeat then...

5


becauuse there are many reasons(???) so i dont know is this a cat, you should know write a program in onch is so diffcult...

70


yeah it wont do something, maybe...

a

The interpreter of Onechar

this interpreter only support number code.

code=5#you can also len("some strings")
values=[code]
k=2
q=[[0,1]]
while code//k>1:
    values.append(code//k)
    code=code//k
    k+=1 if k==2 else 2
pointer=0
while pointer<len(values):
    j=pointer
    i=values[j]
    ttype=0
    ttype=i%3
    if q[-1][1]==2:
        values[j+1 if j<len(values)-1 else 0]+=q[-1][0]
    tnext=i%4 in (0,2)
    if tnext:
        if i%5==0:
            pointer-=2 if pointer>1 else pointer
            continue
        elif i%5==1:
            pointer-=1 if pointer>0 else pointer
            continue
        elif i%5==2:
            top=q[-1][0] if len(q)>0 else 0
            if top<=0:
                continue
        elif i%5==3:
            q[0],q[-1]=q[-1],q[0]
        elif i%5==4:
            q[-1],q[-2]=q[-2],q[-1]
    if ttype>0:
        q.append([i%7,ttype])
    if i%9==1:
        q[-1][0]//=i%7
    elif i%9==2:
        q[-1][0]=int(not q[-1][0])
    elif i%9==3:
        q.pop(0) if len(q)>1 else 0
    if i%9 != 4:
        if i%2:
            print(q[-1][0])
        else:
            q[-1][0]=chr(input()[0])                            
    pointer+=1