We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Lananang
Overview
| Variable Type | Description |
|---|---|
c<FF> |
A byte with the value 0xFF. |
i<128> |
An integer with the value 128. These variables are always stored as 64-bit signed integers with two's complement. |
f<12.8> |
A float with the value 12.8. These are always stored in double precision IEEE 754 format. |
s<~>~>~> Hello, world!> |
A string with the value >>> Hello, world!. ~ is the escape character.
|
l<i<64>,s<Sixty-four>> |
An array containing an integer 64 and a string Sixty-four.
|
b<0> |
A false boolean value. |
q<$<i<5>>> |
A query returning the integer 5.
|
v<> |
The abscence of a value. |
Note that overflows and underflows will not stop execution.
Typecasting can be done using the following format:
s.<f<64.7>> |
Represents the string value s<64.7>.
|
Casting a float to an integer will round down.
Casting a string (list of bytes) to an integer will return v<> if the string is invalid.
Casting a string (list of bytes) to a float will return v<> if the string is invalid.
A v<> cannot be typecasted, and will always return a v<>.
Variables are set using the following format:
![number:i<128>] |
This sets the variable number to the the number 128.
|
and are retrieved using the following format:
=[number] |
This returns the value stored at the variable number.
|
Values in lists are retrieved with Python's list slicing syntax:
=[l[i<0>]] |
This returns the first value stored in the array l.
|
=[l[i<1>:i<4>]] |
This returns values 2 through 4 stored in the array l as an array.
|
Setting a value in a list to v<> removes that value from the list, moving everything past back one.
Queries
Queries, analogous to functions, are variables with the type q. They are first class.
This code sets the variable f to a list variable that holds a list containing an input value, and said value plus five.
Keep in mind, all variables set inside a query are destroyed once it concludes.
![f:q{n}<
![l:l<=[n],=[n]+i<5>>]
$[l]
>]
$[value] marks a return value.
Catching extraneous variables can be specified with a semicolon (;), like this:
![f:l{;n}< ? an array with every variable specified
$=[map{n,q{n}<$<n+5>>}] ? return a list of every specified value plus five
>]
Boolean Comparison
| Operator | Description |
|---|---|
x==y |
Returns b<1> if the two values are equal, or if they're equal when typecasted to each other's types, and b<0> otherwise.
|
x===y |
Returns b<1> if the two values are equal and their types are equal, and b<0> otherwise.
|
x~>y |
Returns b<1> if x is more than y, and b<0> otherwise.
|
x~<y |
Returns b<1> if x is less than y, and b<0> otherwise.
|
Inbuilt Queries
| Query | Description |
|---|---|
=[openRead{list[byte]}] |
Loads the file at the specified file path to an array of bytes. If it can't be read, returns v<>.
|
=[openWrite{list[byte]}] |
Changes the output from the current output to a file path, or to the default stdout if v<> is supplied.
|
=[input{integer (optional)}] |
Reads from stdin until EOF or until the optionally specified length, and returns the read bytes as a list. If stdin cannot be read, returns v<>.
|
=[output{*}] |
Prints anything to the output. Strings are printed byte by byte. |
=[import{list[byte]}] |
Imports the return value after running the .lnag (lananang) file stored at the file path relative to the directory the program was ran in. If it can't be read, returns v<>.
|
=[random{}] |
Returns a random float in the half-open range [0, 1). |
=[round{float / integer}] |
Returns number rounded to the nearest integer, with ties to even. Saturates for floats larger than the bounds of an integer, and returns i<0> for NaN.
|
=[if{boolean, query, query (optional)}] |
Evaluates query 1 if the boolean is true, and if not and it exists, query 2. |
=[loop{query, boolean}] |
Evaluates the query while the boolean is true. |
=[length{array}] |
Returns the length of the input array. |
=[map{list, query}] |
Applies a function to every value in a list and returns the result. |
=[reduce{list, function}] |
Applies a function for every few values in a list (minimum number of arguments in the specified function) and returns the result. (e.g. [=reduce{l<i<1>,i<2>,i<3>,i<4>,i<5>,i{a,b}<$<a+b>>}] returns i<15>)
|
=[type{*}] |
Returns a string containing the specified variable's type. (e.g. =[type{i<1>}] would return s<i>)
|
=[toBytes{boolean / float / integer}] |
Returns a list of bytes containing the specified variable's raw byte representation, in little endian. |
=[fromBytes{list[byte], string[boolean] / string[float] / string[integer]}] |
Returns a value constructed from the raw byte representation of the specified type, in little endian. Will return v<> if the list is not long enough, and will silently ignore extra bytes.
|
If an inbuilt query is passed values of incorrect types, execution will halt.
Math
| Operator | Function |
|---|---|
x+y |
Adds two values |
x-y |
Subtracts two values |
x*y |
Multiplies two values |
x/y |
Divides two values (integer division will halt execution with an error) |
x%y |
Gets the modulo of x to y (integer division will halt execution with an error) |
x^y |
Raises x to the power of y (integer would-be-imaginary results will halt execution with an error) |
x&y |
Bitwise and of two values |
x||y |
Bitwise or of two values |
!!x |
Bitwise not of a value |
x^|y |
Bitwise xor of two values |
Bitwise operators on booleans, integers, or bytes work as one would expect.
Any bitwise operators on floats will operate with their byte representation.
Dividing by 0 is valid for floats, and will return either f<+Inf> or f<-Inf> according to if the number was positive or negative, assuming 0 is positive.
Getting the square root of a negative number will return f<NaN>.
Any invalid computation returns a v<>.
Other Notes
Anything on a line following an unescaped ? is a comment, and will be ignored.
Newlines are ignored except for in strings (where they get parsed as newlines) and in comments.
Trying to retrieve a variable that doesn't exist returns a v<>.
Basic programs
Cat
=[output{input{}}] ? Gets the user input, then prints the output.
Truth machine
![num: ? Set variable num to
i<=[input{}]> ? Input with empty string getting converted to a number
]
=[if{
b<=[num] == i<1>>, ? If variable num is 1:
=[loop{
=[output{ ? Print 1
i<1>
}],
b<1> ? Loop infinitely
}],
=[if{
b<=[num] == i<0>>, ? If variable num is 0:
=[output{ ? Print 0
i<0>
}]
}] ? No other argument so the program ends if it's not 0
}]
Computational class
Not proven to be TC.
Implementations
None