Queue

From Esolang
Jump to: navigation, search

A queue is a data structure sometimes used in esoteric programming languages.

Operations

A queue works by the principle of First In, First Out (FIFO). What is enqueued onto the queue first, will be dequeued first. This leads to the operations ENQUEUE, which puts a value at the back of the queue, and DEQUEUE, which takes a value from the front, removes it, and returns it.

Additional Operations

In addition to ENQUEUE and DEQUEUE, there are a few other queue manipulation operations, many of which are the queue equivalent of stack operations, that queues can use that are generally accomplished through scalar variables.

The following table lists them, including the operation, its name, its traditional (or completely made up) laconic representation, its meaning, and an example in "Generic Queue Language" (GQL), a language used solely for example purposes.

Op Laconic Name Meaning GQL
PEEK N/A Peek Get the value at the front of the queue without removing it Not possible due to the FIFO nature of queues
DROP $ Drop Remove the value from the front of the queue and discard it DEQUEUE;
ROLL N/A Roll Move the value from the front of the queue to the back DEQUEUE→a; ENQUEUE a;
DUP : Duplicate Duplicate the value at the front of the queue to the back PEEK→a; ENQUEUE a;

Use in esolangs

Here are some examples of esoteric programming languages that use queues:

  • Q-Bal works like a stack-based language, except using queues instead of stacks.
  • Qdeql uses a single queue.
  • NULL uses three queues.
  • Fueue uses a single queue.
  • 0815 uses a single queue and 3 registers.

See Also

Category:Queue-based Stack