Expressive

From Esolang
Jump to navigation Jump to search

Expressive is an esoteric programming language created by User:CreeperBomb in 2023. All programs are math expressions (hence the name "Expressive"), with some specific syntax/semantics that make it usable & Turing complete.

Specification

In every step, the expression is evaluated. Afterward, the result is stored and displayed to the user. This repeats until the user stops the program, with the final result of the program being what's printed. The initial value for the program is input. If a multivalued function is involved (e.g. square roots of complex numbers), the user chooses which branch to use at each step as additional input. For even more input options, the keyword input (or an equivalent word in another language) equals input for that step.

To access previous results, and to find which step you're on, you can use and . is equal to the nth previous result, such that is the previous result, is the result before the previous result, etc. if x isn't positive or an integer causes undefined behavior. is equal to which step you're on. For example, on the initial step, n is equal to 1.

Expressions are made of computable mathematical functions, although notation may need to be explained or defined, especially if it is uncommon or ambiguous (such as x!! either being x factorial factorial or x double factorial). While Expressive does support comments, they are very freeform like the expressions themselves — as long as it's clear that it's a comment and not part of the expression, it's a valid program/comment.

Turing completeness

Expressive is trivally Turing complete as it any computable function that exists, provided that it is detailed by the programmer or famous enough to not need this, and is mathematical in nature. However, it is also possible to only use common mathematical functions and maintain Expressive being Turing complete, such as subtraction, multiplication, exponentiation, and absolute valuation.

Examples

(Infinite) cat program:
Integer input: — Uses the complex definition of "ln", which has infinite branches
Truth machine: — Uses a piecewise expression and "join(x, y)", which joins two lists, a list and a number, or two numbers together into one, single list
Deadfish interpreter: — s->0, i->1, d->2, o->3. drop(x, y) removes the yth element of x. […] symbolises a list. length(x) is the length of a list x. The rest is specified in the truth machine
Collatz sequence of a number: — "Collatz sequence" refers to the sequence in the Collatz Conjecture, and the expression uses a piecewise expression