qq is an esoteric language created by User:ehird in 2008. It is based on quoting programs taken to the (il)logical extreme. It's kind of like Underload, but not really, but not at all.
Syntax
Expression
(
expression+)
- integer
Whitespace is ignored, apart from the fact that it can be used to separate integers.
Program
- expression*
Evaluation
If the first element is an integer, we execute it's associated command, with the rest of the program/quoted program, unevaluated, as arguments.
If the first element is a quoted program, we execute it as a toplevel program, then use that as the command number (as above).
Commands
- (arity 1+) The first argument must be an integer, the rest anything. Execute the command numbered by the first argument with the arguments of the rest of the arguments evaluated. (Phew!)
- (arity 1) Return the argument, unscathed.
- (arity 2) Both arguments must be quoted programs. They are munged (concatentated) together.
- (arity 1) Munges the quoted program argument with itself.
- (arity 2) Both arguments must be integers. They are added together.
- (arity 2) Both arguments must be integers. They are subtracted. If a negative value results, they get added instead.
- (arity 0) A character is read from standard input and returned as its ASCII number.
- (arity 1) The argument must be an integer. It is printed out, as its ASCII character, to the screen. Then it is returned.
- (arity 3) The arguments may be anything. If the first argument is 0, the third argument is returned, otherwise the second is returned.
- (arity 1+) The first argument must be an integer. An integer is returned, which when called as a command, is like calling the first argument with the arguments of the rest of the arguments to this command plus the arguments passed to the returned command. (...Of course!)
Examples
One-character cat
Reads one character in, and prints it out.
(0 7(6))
How it works
0 is being called with 7 and (6), so it knows it has to run the command 7, but with what arguments? Well: 0 runs it with the rest of the arguments it gets, but evaluated, unlike a normal call. So: we run the program (6), which calls 6, which reads a character from input and returns it. Then we run 7 with that character, printing it out.
External resources
- Interpreter, written in Common Lisp (dead link) (warning: the dead link currently leads to a porn site.)