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 function 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 RTL, but commands are executed LTR, except for in special cases like loops and if(/else) statements. While +÷abc (infix (a÷b)+c) and +a÷bc (infix a+(b÷c)) are both valid, the latter is preferred.

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.

Commands

Right now, I’m keeping all the commands on a Google Doc. XENBLN uses 256 characters, not all of which are currently assigned to, and will take up only as many characters as it does bytes (unless other characters are used in strings or as variable names). I copied the doc's current state as of June 29th, 2020 to this subpage.

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!"456f0.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 (("[^"]*)|("([^"]*«)*[^"]*).

Number separation

Use the , character to separate two numbers in XENBLN, e.g. [123,456,7.89"str"] (code-golfed: [123,456,7.89"str) would in many languages be [123, 456, 7.89, "str"].

Constants

õ, z, o, etc. represent numbers — these three represent -1, 0, and 1 respectively. 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 -f

Passes user input as the first argument to every command.