XENBLN

From Esolang
Jump to navigation Jump to search

XENBLN is a general-purpose code-golfing language created by User:PythonshellDebugwindow. It uses a character encoding based on the first 256 Unicode characters, but with non-printing characters replaced.

Etymology

The name "XENBLN" is the capitalized Latin-alphabet lookalikes (kind of) of the Cyrillic letters of the Russian transliteration (kind of) of "Jelly" (which is "Желлый"), another code-golfing language.

Program structure

Like @, a program in XENBLN is made of trees of function calls (with some exceptions). These functions utilize prefix notation. Each character (with some exceptions) represents a function that takes a predefined amount of arguments, which follow directly after it in the code, as XENBLN is, again, a prefix language. For example, if command A takes 1 argument, B takes 2, C takes 3, and D and E both take none, then the XENBLN code

  BADCDBEDEDAE

would be written in many languages like

  B(A(D()), C(D(), B(E(), D()), E())));
  D();
  A(E());

Command arguments are evaluated from left to right, as are commands, except for special cases like loops and if/else statements.

Storage

The main method of storage in XENBLN is the Array (not to be confused with the array data types), which is like a stack but much more convenient as you can insert, remove, and change elements at all indexes. It also has a variable system (for example, $a123 would set variable a to 123, $+a100 would increment a by 100, and a would return its value); the main six are a, b, c, l, m, and n (l, m, and n are intended for use in functions, but it really doesn’t matter what you use them for), but all unassigned characters can be used as variables as well, although using them is likely not forwards compatible.

Commands

XENBLN uses 256 commands, not all of which are currently assigned to. The most recent public list of commands is available at XENBLN/Commands.

Datatypes

Datatype Regex Example
Integer [0-9αβγδεζ]+|[০১২৩৪৫৬৭৮৯ηθικλμ]+ 123
Float/Double [0-9αβγδεζ]*\.[0-9αβγδεζ]*|[০১২৩৪৫৬৭৮৯ηθικλμ]*\.[০১২৩৪৫৬৭৮৯ηθικλμ]* [1] 123.45
Boolean [tf] t
String (("[^"]*)|("([^"]*«)*[^"]*)" [2] "Hello, World!"
Array \[(anything)*\] [123t"Hello, World!"456f.5] (in many languages, this would be [123, true, "Hello, World!", 456, false, 0.5])
Undefined û û
NaN ñ ñ
Invalid type ÿ ÿ

Here is a Google Spreadsheet of type conversions, which happen automatically.
[1] If no digits are provided on one or both side(s) of the decimal point, that number is assumed to be 0, e.g. 0.0 = 0. = .0 = ..
[2] Escape characters in strings are as follows: \\ for a backslash, \" for double quotes, \n for newline, \t for tab, \f for form feed, \« (« = string separator) for the character «, and anything else after a backslash means that backslash will be replaced by \\ (escaped backslash). Also, if EOF is reached before a string is terminated, then it will be terminated automatically, meaning that the EOF string regex is (("[^"]*)|("([^"]*«)*[^"]*).

Two number groups

In XENBLN, there are two number number groups, both of which are hexadecimal: group A, the Indo-Arabic digits and Greek letters 0123456789αβγδεζ, and group B, the Bengali numerals and Greek letters ০১২৩৪৫৬৭৮৯ηθικλμ. They are equivalent, and are used only to write two numbers side by side. Digits within each group combine with each other (for example, 123 and ১২৩ are each parsed as one number, 123), but adjacent digits from different groups are separate (for example, 123১২৩ is parsed as two separate numbers, both 123).

Constants

Characters like õ, etc. represent numbers — in this case, -1. There are number, string, and array constants.

I/O Capabilities

Input

There are multiple ways to get input in XENBLN, with different purposes. The I command (0 args) returns user input as an arbitrary-length string (or empty string if no input is given); the N command (0 args) returns user input as an arbitrary-size integer (or 0 if no input is given or if an invalid int/float/double is given); the M command (0 args) returns user input as a float/double or 0.0 if no input or invalid int/float/double; the Ì command (1 arg) returns user input as an integer or 0 if no input or invalid int/float/double, but its argument is first printed out without a newline like a prompt; the ì command (1 arg) returns user input as a string or empty string if no input, but its argument is first printed out without a newline like a prompt; and the í command (1 arg) returns user input as a float/double or 0.0 if no input or invalid int/float/double, but its argument is first printed out without a newline like a prompt.

Output

Like with input, there are multiple commands for output in XENBLN. The O command (1 arg), which outputs its argument and a newline, but has been rendered obsolete (see Automatic output, below), is perhaps the simplest of these; the Œ command (1 arg) outputs its argument without a newline; the Ø command (1 arg) outputs its argument with a newline and then returns it; and the ø command (1 arg) outputs its argument without a newline and then returns it.

Automatic output

If a non-undefined value is computed and is not an argument to a function, it is output with a newline, meaning the O command (1 arg) is only needed for outputting undefined (or possibly so) values.

Examples

Cat (1 byte)

I

Hello, World! (1 byte)

š

Quine (1 byte)

1

Infinite cat (2 bytes)

ŹI

Infinite loop of nops (2 bytes)

ŹÜ

Reverse cat (2 bytes)

VI

Loop while no input (3 bytes)

w!I

Truth-machine (3 bytes)

ČÎx

Reversed iotas (6 bytes)

ÝÓNVÓý

Loop until the user says "stop" (case-insensitive) (9 bytes)

w≠BI"stop

Can be made case-sensitive for 8 bytes by removing the B.

Mean of array (stored in variable a) (12 bytes)

:zŻa:+\x÷\Ga

Interpret PlusOrMinus (29 bytes)

žIË=x„+$àaÍ=x„-ÈãaÍ|=aõ=aâ$az

Interpret Deadfish (probably) (35 bytes)

žISx„i$àaCd$áaCs$²aCoÈa}Í|=aõ=aâ$az

Command-line switches

These switches can be used with any compliant interpreter, if one is ever made.

XENBLN -i

Makes parameter filling use user input instead of undefined. Can shorten programs such as +II to simply +.

XENBLN -n

Prevents automatic output.

XENBLN -o

Only automatically output the last executed expression.