DQ

From Esolang
Jump to navigation Jump to search

DQ is a esolang about duplicate and discard

esolang overview

alphabet

DQ uses a minimal stack-based approach. The only symbols are:

symbols:
symbol description
0 represents an empty stack
1 pushes a 1 onto the stack
D duplicates the top element on the stack
Q discards the top element on the stack

execution model

  • Start with an empty stack.
  • Read the DQ program character by character in random order.
  • After processing the entire program, the final stack contents represent the output.

examples

11DQ

execution:

  • 1: Push a 1 onto the stack (stack: 1).
  • 1: Push another 1 onto the stack (stack: 1, 1).
  • D: Duplicate the top 1 (stack: 1, 1, 1, 1).
  • Q: Discard the top element (stack: 1, 1, 1).

Final output: 1, 1, 1 (if it goes in right direction).

Key Features:

  • Duplication: The D instruction effectively doubles the size of the stack (up to the current stack pointer) at a specific point.
  • Discarding: The Q instruction removes the top element, allowing for selective removal and manipulation of stack contents.
  • All operations happen in a random order