We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Qadi

From Esolang
Jump to navigation Jump to search

Qadi (/qədi/) is a language made by User:Biscat111 in 2026 due to a perceived lack of queue based languages.

It is Turing-complete, and the original creator is planning to write a brainfuck interpreter in Qadi.

Description

Qadi is a queue-based language with 7 instructions.

Command Description
. Adds a 0 to the end of the queue.
+ Increment the value on the front of the queue.
- Decrement the value on the front of the queue, the value is allowed to go negative.
r Copy the value on the front of the queue to the back of the queue, then pop the front value.
i Makes you input a number or a character, depending on if the following character in the code is a "c"
o Outputs a number or a character, depending on if the following character in the code is a "c"
s Always followed by a number N in the code. If the front value of the queue is not 0, jump to the Nth character.

Any other characters are noops.

Programs

Truth Machine:

ios1

Factorial:

i.....-r+r+r+r+r+rs6pr-r-rrrr-rr-r+rrrrs32prr..rrr-r+r+rrrrs50
prr-s30prrpp-r.....-rr+r+r+rrrs81p-rrrr+r+rs96prrr-s123+s128rrrs32rro

Computational class

The language is Turing-complete as a variation of 2-register Minsky machine with "jumo if nonzero" instruction (which we will call PositiveJump) could be translated into it:

PositiveJump syntax and TC proof

  • inc R - increment register R
  • dec R - if register R is nonzero decrement it, if zero do nothing
  • jmpnz R L - if register R is nonzero jump to L

This variation is still Turing-complete, as regular 2-register Minsky machine could be translated ito it:

  • Unconditional jump:
inc R1
jmpnz R1 L

With line L having a dec R1 command at it, so the code is adjusted by adding inc R1 command before line L and command that was intended to jump to bein right after L

  • Decrement and jump to L1 if nonzero, else jump to L2:
jmpnz L0
jmp L2
line L0: dec R
jmp L1

where jmp is unconditional jump

Translating it into Qadi

Our two registers would be represented as two elements at the queue, with current register being at the front
Program starts with .. to initialize two registers. Then other commands are straight forward:

  • inc R1 becomes +r, inc R2 becomes r+
  • dec R1 likewise becomes -r, while dec R becomes r-
  • jmpnz R1 L is also trivial, becoming sL
  • jmpnz R2 L on other hand requies code adjusting, it is translated as rsLr, with command L having r and another r appended before it, while command that jump was performed to being right after L

Note that jump commands never have the same number as PositiveJump command because of the fact that all commands have multiple characters and because of other additional characters added

Interpreter

Python Interpreter, by Biscat111.

code = input("code: ")
codelist = []
#gets code into 1 (one) string
while code != "":
    #print(code)
    codelist.append(code)
    code = input("code: ")     
code = ""
while codelist != []:
    x = codelist[0]
    code += x
    codelist.remove(x)
    
#by Biscat111
code += " "
queue = []
cursor = 0
while cursor < len(code):
   
    if code[cursor] == ".":
        queue.append(0)
   
    if code[cursor] == "+":
        queue[0] += 1
   
    if code[cursor] == "-":
        queue[0] -= 1
   
    if code[cursor] == "p":
        queue.pop(0)
   
    if code[cursor] == "r":
        front = queue.pop(0)
        queue.append(front)
   
    if code[cursor] == "i":
        if code[cursor+1] == "c":
            queue.append(ord(input("input character: ")))
        else:
            queue.append(int(input("input number: ")))

    if code[cursor] == "o":
        if code[cursor+1] == "c":
            print(chr(queue[0]), end="", flush=True)
        else:
            print()
            print(queue[0])
   
    if code[cursor] == "s":
        if queue[0] != 0:
            cursor += 1
            adress = 0
            #is the character between 0 and 9
            while 47 < ord(code[cursor]) < 58:
                digit = int(code[cursor])
                cursor += 1
                adress *= 10
                adress += digit
            cursor = adress-1
            #other debugging tool
            #print(code[(cursor+1):])
            #print("s")
   
    #debugging tools
    #print(code[cursor])
    #print(queue)
    #print(cursor)
    #if cursor > 100:
    #    pass #debugging
    cursor += 1