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.
DQ
Jump to navigation
Jump to search
DQ is a esolang about duplicating and discarding values, created by User:Yayimhere.
esolang overview
alphabet
DQ is an incredibly small language. The only symbols are:
| symbol | description |
|---|---|
| 0 | make the stack empty |
| 1 | pushes a 1 onto the stack |
| D | duplicates the top element on the stack |
| Q | discards the top element on the stack |
the order of commands is shuffled every run.
Implementations
Written in JavaScript.
function dq(program)
{
const stack = [];
const randomisedProgram = program.split("").sort(() => Math.random() - 0.5);
for(const character of randomisedProgram)
{
switch(character)
{
case "0":
stack.length = 0;
break;
case "1":
stack.push(1);
break;
case "D":
if(stack.length > 0)
stack.push(stack[stack.length - 1]);
break;
case "Q":
stack.pop();
break;
}
}
console.log(...stack);
}
A python interpriter by User:Ractangle:
import random
s=[];p=0
tempi=input()
acti=[]
for _ in tempi:acti.append(_)
random.shuffle(acti)
for _ in acti:
if _=="0":s.clear()
if _=="Q":s.pop()
if _=="D":s.append(s[-1])
if _=="1":s.append(1)
print(s)