Built-in types
Bool
Boolean type. Bool has two possible values: 0B and 1B {…the main reason for rejection of true and false {…11l is not the only one programming language in which boolean values are not true and false: for example, in Objective-C the pair YES/NO is used, and in Scheme: #t and #f} is that keywords do not fit into the base concept of 11l — all root {…for example,
L— is a root keyword, and
breakis a subkeyword} keywords can be shortened to one letter {…there is an option to do it with Bool values: take Y as Yes/true and O as nO/false/0, but this is even more ugly than 0B and 1B, and also then language should be renamed to 13l}}. [Like in Boolean algebra, in which 0 and 1 are used.]
Int
Integral type (32 or 64 bits).
Int8/Byte
Int16
Int32
Int64
or
Int1/Byte
Int2
Int4
Int8
Float
Floating-point type (32 or 64 bits).
Float32
Float64
or
Float4
Float8
Char
Character. For example this code creates a character with code 65:
Char(code' 65)Members
code
Code of the character.
MethodsCode of the character.
is_digit()
Return true (1B) if character is a digit.
is_alpha()
Return true (1B) if character is an alphabetic.
is_lowercase()
Return true (1B) if character is lowercase.
is_uppercase()
Return true (1B) if character is uppercase.
lowercase()
Return a copy of the character converted to lowercase.
uppercase()
Return a copy of the character converted to uppercase.
Return true (1B) if character is a digit.
is_alpha()
Return true (1B) if character is an alphabetic.
is_lowercase()
Return true (1B) if character is lowercase.
is_uppercase()
Return true (1B) if character is uppercase.
lowercase()
Return a copy of the character converted to lowercase.
uppercase()
Return a copy of the character converted to uppercase.
String
String type. Can be constructed from a string literal.
Note: in contrast to Python, strings in 11l are mutable (like in C++).
Members
len
Length of the string in characters.
MethodsLength of the string in characters.
last
A last character of the string. (This method is called without parens.)
starts_with(prefix)
Return true (1B) if the string starts with the
ends_with(suffix)
Return true (1B) if the string ends with the specified
count(sub)
Return the number of non-overlapping occurrences of substring
is_digit()
Return true (1B) if all characters in the string are digits and there is at least one character, false (0B) otherwise.
is_alpha()
Return true (1B) if all characters in the string are alphabetic and there is at least one character, false (0B) otherwise.
find(sub, start = 0)
Return the lowest index in the string where substring
findi(sub, start = 0)
Return the lowest index in the string where substring
rfind(sub[, start])
Return the highest index in the string where substring
rfindi(sub, start, end)
Return the highest index in the string where substring
replace(old, new)
Return a copy of the string with all occurrences of
lowercase()
Return a copy of the string with all the cased characters converted to lowercase.
uppercase()
Return a copy of the string with all the cased characters converted to uppercase.
capitalize()
Return a copy of the string with its first character capitalized.
zfill(width)
Return a copy of the string left filled with ASCII '0' digits to make a string of length
center(width, fillchar = ‘ ’)
Return centered in a string of length
ljust(width, fillchar = ‘ ’)
Return the string left justified in a string of length
rjust(width, fillchar = ‘ ’)
Return the string right justified in a string of length
split(delim, limit = N, group_delimiters = 0B)
Divides string into substrings based on a delimiter, returning an array of these substrings.
If
ltrim(string[, limit])
Return a copy of the string with leading strings removed. At most
ltrim(tuple_of_chars[, limit])
Return a copy of the string with leading characters removed. At most
rtrim(string[, limit])
Return a copy of the string with trailing strings removed. At most
Example:
rtrim(tuple_of_chars[, limit])
Return a copy of the string with trailing characters removed. At most
Example:
trim(string)
Return a copy of the string with leading and trailing strings removed.
trim(tuple_of_chars)
Return a copy of the string with leading and trailing characters removed.
format(args...)
Perform a string formatting operation. The string on which this method is called can contain literal text or replacement fields starting with
Format String Syntax
Examples:
A last character of the string. (This method is called without parens.)
starts_with(prefix)
Return true (1B) if the string starts with the
prefix, otherwise return false (0B).
prefixcan also be a tuple of prefixes to look for.
ends_with(suffix)
Return true (1B) if the string ends with the specified
suffix, otherwise return false (0B).
suffixcan also be a tuple of suffixes to look for.
count(sub)
Return the number of non-overlapping occurrences of substring
sub.
is_digit()
Return true (1B) if all characters in the string are digits and there is at least one character, false (0B) otherwise.
is_alpha()
Return true (1B) if all characters in the string are alphabetic and there is at least one character, false (0B) otherwise.
find(sub, start = 0)
Return the lowest index in the string where substring
subis found. Search begins at
start. Return
N/
nullif
subis not found.
subcan also be a tuple of strings to look for.
findi(sub, start = 0)
Return the lowest index in the string where substring
subis found. Search begins at
start. Return
-1if
subis not found.
rfind(sub[, start])
Return the highest index in the string where substring
subis found. Search begins at
start(if
startis not specified, whole string will be searched). Return
N/
nullif
subis not found.
rfindi(sub, start, end)
Return the highest index in the string where substring
subis found, such that
subis contained within
s[start.<end]. Return
-1if
subis not found.
replace(old, new)
Return a copy of the string with all occurrences of
oldreplaced by
new.
oldcan be a regular expression.
lowercase()
Return a copy of the string with all the cased characters converted to lowercase.
uppercase()
Return a copy of the string with all the cased characters converted to uppercase.
capitalize()
Return a copy of the string with its first character capitalized.
zfill(width)
Return a copy of the string left filled with ASCII '0' digits to make a string of length
width.
center(width, fillchar = ‘ ’)
Return centered in a string of length
width. Padding is done using the specified
fillchar.
ljust(width, fillchar = ‘ ’)
Return the string left justified in a string of length
width. Padding is done using the specified
fillchar.
rjust(width, fillchar = ‘ ’)
Return the string right justified in a string of length
width. Padding is done using the specified
fillchar.
split(delim, limit = N, group_delimiters = 0B)
Divides string into substrings based on a delimiter, returning an array of these substrings.
delimcan be a regular expression.
delimcan also be a tuple of characters (example:
s.split((‘ ’, "\t", "\n", "\r"))). If
limitis given, at most that number of fields will be returned (if
limitis 1, the entire string is returned as the only entry in an array). [
limitargument in 11l is similar to JavaScript, Ruby and PHP, but not Python.]
If
group_delimitersis
0B, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example,
‘1,,2’.split(‘,’)returns
[‘1’, ‘’, ‘2’]).
ltrim(string[, limit])
Return a copy of the string with leading strings removed. At most
limitstrings are removed.
ltrim(tuple_of_chars[, limit])
Return a copy of the string with leading characters removed. At most
limitcharacters are removed.
rtrim(string[, limit])
Return a copy of the string with trailing strings removed. At most
limitstrings are removed.
Example:
‘1.0.0’.rtrim(‘.0’, 1)returns
‘1.0’
.rtrim(tuple_of_chars[, limit])
Return a copy of the string with trailing characters removed. At most
limitcharacters are removed.
Example:
‘a.,’.rtrim((‘.’, ‘,’))returns
‘a’
.trim(string)
Return a copy of the string with leading and trailing strings removed.
trim(tuple_of_chars)
Return a copy of the string with leading and trailing characters removed.
format(args...)
Perform a string formatting operation. The string on which this method is called can contain literal text or replacement fields starting with
#. Returns a copy of the string where each replacement field is replaced with the string value of the corresponding argument.
Format String Syntax
replacement_field ::= "#"["<"](width["."precision] | "."[precision]) width ::= digit+ precision ::= digit+
Examples:
Replacement field | Argument | Output |
---|---|---|
#4. | 40 | 40. |
#4 | 4 | 4 |
#4 | 1.2 | 1.2 |
#04 | 1.2 | 01.2 |
#. | 1.234 | 1.234 |
#.6 | 1.234 | 1.234000 |
#2.6 | 1.234 | 1.234000 |
#2.2 | 1.234 | 1.23 |
#2.2 | -1.234 | -1.23 |
#2 | 1 | 1 |
#5 | abc | abc |
#. | abc | abc |
#<5. | abc | abc . |
That's like rule ###.. | 1 | That's like rule #1. |
Tuple
A tuple. For example, a tuple with two items:
(1, 2). [Type of this tuple is
(Int, Int).]
The elements of tuples consisting of from 2 to 4 elements of the same type can be accessed by
x,
y,
z,
wor
r,
g,
b,
a.
Arithmetic operations (
+,
-,
*,
/) on tuples are performed componentwise {…for example,
(x1, y1, z1) + (x2, y2, z2)will give the following tuple:
(x1 + x2, y1 + y2, z1 + z2){…and
(x, y, z) * 2will give
(x*2, y*2, z*2)}}.
Note 1: like in mypy, tuples in 11l are heterogeneous, but arrays (analogue of Python's lists) are homogeneous.
Note 2: in contrast to Python, tuples in 11l are mutable (like in C++).
Array
An array. For example, an array with two items:
[1, 2]. [Type of this array is
[Int].]
Members
len
Length of an array.
MethodsLength of an array.
last
A last element of the array. (This method is called without parens.)
join(sep)
Return a string which is the concatenation of the strings in an array.
map(function)
Applies
filter(function)
Return a new array consisting of those elements from this array for which
reduce([initial,] function)
Apply
[Note that order of the arguments is the same as in Java, in Swift and in Rust, but not in Python.]
append(new_element)
Appends
append(arr)
Appends all elements of
append(range)
Append all values of
arr [+]= x
The same as
pop()
Retrieves the last item of this array and also removes it.
index(x, start = 0)
Return index of the first occurrence of
find(x, start = 0)
Return index of the first occurrence of
count(x)
Return total number of occurrences of
sort()
This method sorts the array in place, using only
sort_range(range)
This method sorts the specified range of an array in place.
reverse()
Reverses the items of array in place.
A last element of the array. (This method is called without parens.)
join(sep)
Return a string which is the concatenation of the strings in an array.
sepis the separator between elements.
map(function)
Applies
functionto every item of an array and return that new array.
filter(function)
Return a new array consisting of those elements from this array for which
functionreturns true (1B).
reduce([initial,] function)
Apply
functionof two arguments cumulatively to the items of the array, from left to right, so as to reduce the array to a single value. For example,
[1, 2, 3].reduce((x, y) -> x + y)calculates
((1+2)+3). If the optional
initialis present, it is placed before the items of the array in the calculation, and serves as a default when the array is empty.
[Note that order of the arguments is the same as in Java, in Swift and in Rust, but not in Python.]
append(new_element)
Appends
new_elementto the end of this array.
append(arr)
Appends all elements of
arrto the end of this array.
append(range)
Append all values of
rangeto the end of this array. Example: {…
V arr = [-1] arr.append(1..3) print(arr) // will print [-1, 1, 2, 3]}
arr [+]= x
The same as
arr.append(x).
pop()
Retrieves the last item of this array and also removes it.
index(x, start = 0)
Return index of the first occurrence of
xin this array (at or after index
start).
ValueErroris raised when
xis not found in this array.
find(x, start = 0)
Return index of the first occurrence of
xin this array (at or after index
start), or
N/
nullif
xis not found in this array.
xcan also be a tuple of values to look for.
count(x)
Return total number of occurrences of
xin this array.
sort()
This method sorts the array in place, using only
<comparisons between items.
sort_range(range)
This method sorts the specified range of an array in place.
reverse()
Reverses the items of array in place.
Dict
A dictionary. For example, a dictionary with two items:
[‘key1’ = 1, ‘key2’ = 2]. [Type of this dictionary is
[String = Int].]
Methods
find(key) -> ValueType?
Finds element with specific key. If no such element is found,
get(key, default) -> ValueType
Return the value for
keys()
Return an array of the dictionary's keys.
values()
Return an array of the dictionary's values.
filter(function)
Return an array consisting of those elements of dictionary for which
Finds element with specific key. If no such element is found,
N/
nullis returned.
get(key, default) -> ValueType
Return the value for
keyif
keyis in the dictionary, else
default.
keys()
Return an array of the dictionary's keys.
values()
Return an array of the dictionary's values.
filter(function)
Return an array consisting of those elements of dictionary for which
functionreturns true (1B).
DefaultDict
A dictionary, which does not throw an exception when accessing a non-existent key (it inserts a new item with a default value in this case).
Set
A set.
Methods
add(elem)
Add element
remove(elem)
Remove element
clear()
Remove all elements from the set.
difference(other)
Return a new set with elements in the set that are not in the
lower_bound(key) -> KeyType?
Returns the first element which is not less than the given
upper_bound(key) -> KeyType?
Returns the first element which is greater than the given
Add element
elemto the set.
remove(elem)
Remove element
elemfrom the set. Raises
KeyErrorif
elemis not contained in the set.
clear()
Remove all elements from the set.
difference(other)
Return a new set with elements in the set that are not in the
other.
lower_bound(key) -> KeyType?
Returns the first element which is not less than the given
key. If no such element is found,
N/
nullis returned.
upper_bound(key) -> KeyType?
Returns the first element which is greater than the given
key. If no such element is found,
N/
nullis returned.
Deque
A double-ended queue.
Methods
append(x)
Add
append_left(x)
Add
clear()
Remove all elements from the deque leaving it with length 0.
extend(iterable)
Extend the right side of the deque by appending elements from the iterable argument.
extend_left(iterable)
Extend the left side of the deque by appending elements from
index(x, start = 0)
Return the position of
insert(i, x)
Insert
pop()
Remove and return an element from the right side of the deque. If no elements are present, raises an
pop_left()
Remove and return an element from the left side of the deque. If no elements are present, raises an
remove(value)
Remove the first occurrence of
Add
xto the right side of the deque.
append_left(x)
Add
xto the left side of the deque.
clear()
Remove all elements from the deque leaving it with length 0.
extend(iterable)
Extend the right side of the deque by appending elements from the iterable argument.
extend_left(iterable)
Extend the left side of the deque by appending elements from
iterable.
index(x, start = 0)
Return the position of
xin the deque (at or after index
start). Returns the first match or raises
ValueErrorif not found.
insert(i, x)
Insert
xinto the deque at position
i.
pop()
Remove and return an element from the right side of the deque. If no elements are present, raises an
IndexError.
pop_left()
Remove and return an element from the left side of the deque. If no elements are present, raises an
IndexError.
remove(value)
Remove the first occurrence of
value. If not found, raises a
ValueError.
File
A file object.
Methods
File(name, mode = ‘r’)
Open file with the specified name and mode (note: only ‘r’ and ‘w’ are supported at the present moment).
read() -> String
Read a whole file into a string, and return it.
Note: only UTF-8 encoding [with optional BOM] is supported at the present moment.
read_line(keep_newline = 0B) -> String
Read and return one line from the file. If
read_lines(keep_newline = 0B) -> Array[String]
Reads the entire file as individual lines, and returns those lines in an array. If
read_bytes() -> Array[Byte]
Read a whole file into an array of bytes, and return it.
write(s)
Write the string
write_bytes(Array[Byte] bytes)
Write bytes to the file.
flush()
Flush the write buffers of the file.
Open file with the specified name and mode (note: only ‘r’ and ‘w’ are supported at the present moment).
read() -> String
Read a whole file into a string, and return it.
Note: only UTF-8 encoding [with optional BOM] is supported at the present moment.
read_line(keep_newline = 0B) -> String
Read and return one line from the file. If
keep_newlineargument is true (1B), trailing new-line character is left as is.
read_lines(keep_newline = 0B) -> Array[String]
Reads the entire file as individual lines, and returns those lines in an array. If
keep_newlineargument is true (1B), trailing new-line characters are left as is.
read_bytes() -> Array[Byte]
Read a whole file into an array of bytes, and return it.
write(s)
Write the string
sto the file.
write_bytes(Array[Byte] bytes)
Write bytes to the file.
flush()
Flush the write buffers of the file.