Interlude

From Esolang
Jump to navigation Jump to search

Interlude is an esolang by User:PythonshellDebugwindow.

Syntax

Interlude programs are two-dimensional. Each program is divided into acts, which are like programs in themselves. Acts are separated by pipes (|), which form vertical lines called interludes. Acts are rectangular.

This means that the program

AAA|BB|CCCC
AAA|BB|CCCC
AAA|BB|CCCC

consists of three acts, each one consisting of 9 As, 6 Bs, and 12 Cs respectively.

At least two acts must be entered over the course of a program.

Execution

The program starts executing at the top-left character of the first act. Acts are executed from left to right, then top to bottom.

For example, the act

ABC
DEF
GHI

would be executed in alphabetical order.

If the bottom-right character of an act is reached, then the program is exited; if less than two acts have been entered during the program, then an error is thrown.

Memory

Interlude uses a queue. Dequeuing from an empty queue returns zero.

Commands

Command Effect
v Move the IP down a line; if the IP is on the last line, then quit the program
$ Dequeue an integer n and go to the top-left character of the one-indexed nth act
+ Dequeue an integer n; if n is greater than zero, then dequeue n more integers and enqueue their sum, otherwise dequeue an integer and print its ASCII value
* If the next character is a digit 0-9, enqueue it; if it is alphabetic, enqueue its ASCII value; if the next character c is a minus sign, then enqueue the result of subtracting *c from zero (if the character after the minus sign is not alphanumeric, then dequeue an element as normal, but enqueue zero); otherwise, dequeue an element and discard it
? If the next character is a period, input a character and enqueue its ASCII value; if the next character is a command listed in this table, skip it if the element that would be dequeued from the queue next is nonzero (but don't dequeue the element); otherwise, empty the queue
: Throw an error and quit the program (can be used as padding if it will never be executed)

The commands * and ? will skip their following character, if there is one (* can skip two characters in some cases, and ? can skip an entire * or ? command; see #Truth-machine for an example of the latter behaviour). All alphanumeric characters print themselves. Spaces (ASCII 32) cannot appear in a program. All other characters will enqueue 78 into the queue, cause the IP to move to a random act, and change the character directly below the IP (if there is one) to v in that order.

Computational class

Interlude is Turing complete by simulating tag.

To convert a tag system into Interlude:

  • Every symbol is now a letter
  • Each symbol has an associated act, with all acts being a single line
  • The first act is the initial act which contains a number of enqueues followed by a $, e.g. the initial queue ab corresponds to the act *A*B$
  • Many padding acts are inserted to reach the ASCII letters (64 empty acts if using A, B, ...)
  • Each symbol act is either:
    • A number of dequeues followed by enqueues, ending with $, like a -> abca in a 2-tag system corresponds to *:*A*B*C*A$. The initial *: pops, with the final $ jumping to the next head symbol's production.
    • A sole v for halting symbols


Examples

Hello, world!

Hello*5*9*9*9*9*8*0++*4*9*9*9*5*0++world*4*9*9*9*6*0++*2$|v

Cat program

*0?.+*2$|*1$

Truth-machine

*4*-A*9*8?.+?v?_*2$|?_1*2$|v
*:0*3$:::::::::::::|::::::|v

Note that the second ? can skip the entire *1 after it. Note also the extensive use of : as padding.

Dice roll

&|1|2|3|4|5|6

Outputs a random number from 1 to 6. & is used to jump to a random act, since it is not a command.

Interpreter

  • Common Lisp implementation of the Interlude programming language.