Exp

From Esolang
Jump to navigation Jump to search

Exp (short for "Expression") is an esoteric programming language based on expressions, created by User:PythonshellDebugwindow.

Instructions

Instruction Meaning
< Open expression
> Close expression
{ Print the ASCII value of the expression/variable inside this pair of curly braces
} See above
{{ Print the integer value of the expression/variable inside this double pair of curly braces
}} See above
@ Sets the variable to the right to the result of the previous expression (the accumulator is the only variable)
~ The accumulator variable; can be used with @, put inside {} or {{}}, or used in an expression

Each {...} and {{...}} must be on its own line. They cannot be nested. Lines can be blank; non-blank lines must contain either {...} or {{...}}.

Expressions

Expressions are defined by < and >. Empty expressions (with no values) are invalid. Values in expressions can be represented by adding the appropriate amount of ^s between 2 |s, e.g. 5 would be represented as |^^^^^|; you could also add no ^s for the value to become 0. You could also use the accumulator's value by using ~ instead of |value|, or a user input character by using I. Values are separated by operations, which are + (addition), - (subtraction), x (multiplication), and / (division). Instead of using the order of operations, operations are read from left-to-right, and there are no parentheses.

Spaces

Spaces can only appear beside operators, <, >, or other spaces.

Examples

"HELLO WORLD"

{<|^^^^^^^^^| x |^^^^^^^^|>}
{<|^^^^^^^^^^| x |^^^^^^^| - |^|>}
{<|^^^^^^^^^| x |^^^^^^^^| + |^^^^|>}
{<|^^^^^^^^^| x |^^^^^^^^| + |^^^^|>}
{<|^^^^^^^^^^| x |^^^^^^^^| - |^|>}
{<|^^^^^^^^| x |^^^^|>}
{<|^^^^^^^^^^| x |^^^^^^^^^| - |^^^|>}
{<|^^^^^^^^^^| x |^^^^^^^^| - |^|>}
{<|^^^^^^^^^^| x |^^^^^^^^| + |^^|>}
{<|^^^^^^^^^| x |^^^^^^^^| + |^^^^|>}
{<|^^^^^^^^^^^^^^^^^| x |^^^^|>}

Cat program (1 character)

{<I>}

Add two inputs

More complicated than it needs to be, but it shows off the accumulator. Takes inputs as ASCII characters, outputs an integer.

{{<I>}}@~
{{<~ + I>}}@~
{{<~>}}

Note that the following program is equivalent:

{<I>}@~
{<~ + I>}@~
{{<~>}}

External resources