Q

From Esolang
Jump to: navigation, search

The Qabalah language (Q) is not only an esoteric programming language, but it is also an occult programming language. The first version of the language was conceived while in bed with my mobile device and a C compiler app, and the program was a fully functional interpreter in 112 lines - with only a very narrow set of operators, and a brainfuck type of variable selection. The code was then transferred to my computer, and the language started developing into what it is today.

Language overview

When Q is run, it creates an environment containing 22 variables, and a stack for 55 blocks; this is what the programmer can make use of. The variables are accessed with latin or Hebrew (UTF-8 unicode) letters, one letter names one variable, and naming a variable places it in the slot V0 and pushes the previous variable to V1, which in turn is pushed to V2 (there is no V3). These three slots are then operated upon by the operators. All letters are references to the variables, therefore some variables are shared by many letters, e.g. O, U, V point to the same variable, named Vav.

There are 22 operator signs, !#%&'()*+-/:<=>?@[]^|~, which can be used as single operators, or be combined into double operators with additional functionality, e.g. ++, >= etc. Some combined operators are recognised from other languages, and others are entirely unique to Q, e.g. -+ which is an operator for abs (a = abs(a);).

Examples

Hello, World!

A Hello world-program, creating a string and printing it:

'Hello, World!' &

Another way, print directly:

?>Hello, World!

Fibonacci sequence

A program printing the Fibonacci sequence, starting with zero:

A 'Fibonacci &C:^&D\'  /* create string */
B10 C0 D0 E1 F+        /* initialise variables */
[                      /* block */
  BC++ <= ?            /* if(++C <= B) */
  A&                   /* output A */
  ED: FE: DF+:         /* D = E, E = F, F += D; */
  @<                   /* loop from start of block */
]

Above program will output:

Fibonacci 1:   0
Fibonacci 2:   1
Fibonacci 3:   1
Fibonacci 4:   2
Fibonacci 5:   3
Fibonacci 6:   5
Fibonacci 7:   8
Fibonacci 8:   13
Fibonacci 9:   21
Fibonacci 10:  34

External resources

  • [1] Complete documentation of the language
  • [2] About the Qabalah

Notable implementations

  • [3] Q interpreter implementation