Type | Range | Operators and comments |
---|---|---|
i8, byte |
-128 .. 127 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
u8, ubyte |
0 .. 255 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
i16, short |
-32768 .. 32767 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
u16, ushort |
0 .. 65535 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
i32, int |
-2147483648 .. 2147483647 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
u32, uint |
0 .. 4294967295 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
i64, long |
-9223372036854775808 .. 9223372036854775807 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
u64, ulong |
0 .. 18446744073709551615 | +, -, *, /, % <<, >>, &, |, ^ <, <=, ==, !=, >=, > |
f32, float |
3.4e-38 .. 3.4e38 can be negative |
+, -, *, /, % <, <=, ==, !=, >=, > |
f64, double |
1.7e-308 .. 1.7e308 can be negative |
+, -, *, /, % <, <=, ==, !=, >=, > |
bool | false, true | &&, ||, ^ <, <=, ==, !=, >=, > ! &&&, ||| (lazy evaluated, can not be overloaded) |
string | standard C string | + <, <=, ==, !=, >=, > |
char | standard C character | +, - <, <=, ==, !=, >=, > |
handle | none | ==, != |
file | - | (copyable) (not default constructible object) |
dir | - | (copyable) (not default constructible object) |
seq<T> | T is a type | (copyable) |
record | - | (create, copyable, member access) |
private record | - | (create, copyable) |
limited record | - | (not copyable when imported) (not default constructible when imported) |
datatype | - | (properties depends on the datatype) |
function | - | (copyable) (not default constructible) |
enum | - | (copyable) <, <=, ==, !=, >=, >
|
Keyword | Example | Description |
---|---|---|
mutable | ..., mutable string s, ... | Can only be used in function argument. Tells the compiler the content of the passed object can be altered. Note that, the object itself can not be replaced. |
Name | Signature | Description |
---|---|---|
write | (string) [impure] | Write string to the standard output. |
read | () : string [impure] | Read a line from the standard input. |
read | (char delim) : string [impure] | Read a delim terminated string from the standard input. |
ror | (T, T) : T | Rotate right. T can be: i8, u8, i16, u16, i32, u32, i64, u64. |
sqrt | (T) : T | Calculate square root of number (optimized algorithm for integers). T can be: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64. |
log | (T) : T | Calculate e-based logarithm. T can be: f32, f64. |
exp | (T) : T | Calculate e-based exponentional. T can be: f32, f64. |
pow | (T a, T b) : f64 | Calculate a^b. T can be: f32, f64. |
sin | (T) : T | Calculate the sine (in radian). T can be: f32, f64. |
cos | (T) : T | Calculate the cosine (in radian). T can be: f32, f64. |
tan | (T) : T | Calculate the tangent (in radian). T can be: f32, f64. |
asin | (T) : T | Calculate the arcsine (in radian). T can be: f32, f64. |
acos | (T) : T | Calculate the arccosine (in radian). T can be: f32, f64. |
atan | (T) : T | Calculate the arctangent (in radian). T can be: f32, f64. |
atan2 | (T y, T x) : T | Calculate the arctangent of y/x (in radian). T can be: f32, f64. |
strcmp | (string a, string b) : i32 | Compare strings (case sensitive). Return <0 if a<b; 0 if a==b; >0 if a>b. |
stricmp | (string a, string b) : i32 | Compare strings (case insensitive). Return <0 if a<b; 0 if a==b; >0 if a>b. |
streq | (string a, string b) : bool | Same as strcmp(a, b)==0 |
strieq | (string a, string b) : bool | Same as stricmp(a, b)==0 |
strne | (string a, string b) : bool | Same as strcmp(a, b)!=0 |
strine | (string a, string b) : bool | Same as stricmp(a, b)!=0 |
strcat | (string, string) : string | Concatenate the two strings. |
trim | (string) : string | Trim the white spaces from the beginning and from the end of a string. |
trim | (string, string) : string | Trim the characters in the second string from the beginning and from the end of first string. |
strrev | (string) : string | Return the argument in reverse. |
substr | (string str, u32 offs) : string | Return the part of the string from the offset to the end. |
substr | (string str, u32 offs, u32 count) : string | Return the part of the string. |
startswith | (string str, string prefix) : bool | Return true if the second string is prefix of the first string, false otherwise. |
endswith | (string str, string suffix) : bool | Return true if the second string is suffix of the first string, false otherwise. |
empty | (string) : bool | Return the fact that the string is an empty string or not. |
chars | (char c, u32 n) : string | Return a string consisting of n of character c. |
chars | (char c, u32 n, string tl) : string | Return a string consisting of n of character c, and ends with tl. |
copies | (string s, u32 n) : string | Return a string containing of s repeated n times. |
copies | (string s, u32 n, string tl) : string | Return a string containing of s repeated n times, and ends with tl. |
strcpy | (mutable string dstr, u32 doff, string sstr, u32 soff, u32 len) | Copy len characters to doffth character of dstr from soffth character of sstr. |
strstr | (string haystack, string needle) : u32 | Return the offset of the first occurrence of needle in haystack; or length of haystack if not found. |
strstr | (string haystack, u32 start, string needle) : u32 | Return the offset of the first occurrence of needle in haystack from the startth character; or length of haystack if not found. |
strrstr | (string haystack, string needle) : u32 | Return the offset of the last occurrence of needle in haystack; or length of haystack if not found. |
strrstr | (string haystack, u32 start, string needle) : u32 | Return the offset of the last occurrence of needle in haystack from the startth character; or length of haystack if not found. |
strchr | (string s, char c) : u32 | Return the offset of the first occurrence of c in s; or length of s if not found. |
strchr | (string s, u32 n, char c) : u32 | Return the offset of the first occurrence of c in s from the nth character; or length of s if not found. |
strrchr | (string s, char c) : u32 | Return the offset of the last occurrence of c in s; or length of s if not found. |
strrchr | (string s, u32 n, char c) : u32 | Return the offset of the last occurrence of c in s from the nth character; or length of s if not found. |
strspn | (string s, string accept) : u32 | Return the length (in characters) of the inital segment of s which consists entirely of characters in accept. |
strspn | (string s, u32 n, string accept) : u32 | Return the length (in characters) of the inital segment of s which consists entirely of characters in accept. The first n characters are ignored. |
strcspn | (string s, string reject) : u32 | Return the length (in characters) of the inital segment of s which consists entirely of characters not in reject. |
strcspn | (string s, u32 n, string reject) : u32 | Return the length (in characters) of the inital segment of s which consists entirely of characters not in reject. The first n characters are ignored. |
strtok | (string str, string sep) : seq<string> | Return the sequence of tokens found in str separeted by sep characters. |
strlen | (string) : u32 | Return the length of the string. |
strlower | (string) : string | Return the string in lowercase. |
strupper | (string) : string | Return the string in uppercase. |
fromutf8 | (string) : string | Converts UTF-8 string to ANSI code page; can raise UnicodeErrorException exception. |
toutf8 | (string) : string | Converts ANSI string to UTF-8 string; affects only code points above 127. |
chartostring | (char) : string | Convert a single character to string. |
getstrchar | (string s, u32 i) : char | Same as s[i] |
setstrchar | (string s, u32 i, char ch) : string | Return the string, but i-th character is replaced with ch. |
charcmp | (char a, char b) : i32 | Compare two characters (case sensitive). Return <0 if a<b; 0 if a==b; >0 if a>b. |
charadd | (char, char) : char | Add two characters, resulting an other character. |
charsub | (char, char) : char | Subtract two characters, resulting an other character. |
charinc | (char ch, i32 i) : char | Calculate (ch+i) mod 256. |
+ | (char ch, T i) : char | Calculate (ch+i) mod 256. T can be: i8, u8, i16, u16, i32, u32. |
chardiff | (char, char) : i32 | Return the difference between the ASCII codes of the characters. |
tolower | (char) : char | Return the lowercase version of ASCII characters. |
toupper | (char) : char | Return the uppercase version of ASCII characters. |
tos | (T) : string | Convert to string. T can be: string, char, bool, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64. |
tobool | (string) : bool | Convert string to boolean. (true, on, 1, yes) |
toi32 | (T) : i32 | Convert to i32. May raise ConstraintErrorException. T can be: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char. |
tou32 | (T) : u32 | Convert to u32. May raise ConstraintErrorException. T can be: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char. |
toi64 | (T) : i64 | Convert to i64. May raise ConstraintErrorException. T can be: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char. |
tou64 | (T) : u64 | Convert to u64. May raise ConstraintErrorException. T can be: i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char. |
tof32 | (T) : f32 | Convert to f32. May raise ConstraintErrorException. T can be: i32, u32, i64, u64, f32, f64. |
tof64 | (T) : f64 | Convert to f64. May raise ConstraintErrorException. T can be: i32, u32, i64, u64, f32, f64. |
tochar | (T) : char | Convert to character. May raise ConstraintErrorException. T can be: i8, u8, i16, u16, i32, u32, i64, u64, char. |
nullhandle | () : handle | Return the null handle. |
empty | (seq<T>) : bool | Return the fact that the sequence is empty or not. |
seqlen | (seq<T>) : u32 | Return the number of elements in the sequence. |
loext | (seq<T>, T) : seq<T> | Append an element to the low end. |
hiext | (seq<T>, T) : seq<T> | Append an element to the high end. |
lorem | (seq<T>) : seq<T> | Remove an element from the low end. |
hirem | (seq<T>) : seq<T> | Remove an element from the high end. |
lov | (seq<T>) : T | Return the element at the low end. |
hiv | (seq<T>) : T | Return the element at the high end. |
lopop | (seq<T>) : seq<T>, T | Remove and return the element at the low end. |
hipop | (seq<T>) : seq<T>, T | Remove and return the element at the high end. |
seqfill | (T elem, u32 count) : seq<T> | Create a new sequence filled with the specified number of the specified element. |
subseq | (seq<T> s, u32 offs, u32 count) : seq<T> | Return the part of the sequence. |
faccess | (string, i32) : bool [impure] | Check access rights (2: read, 4: write, can be ORd). |
fopen | (string, char) : file [impure] | Open a file ('r': read, 'w': write, 'a': append). |
feof | (file) : bool [impure] | Check whether the file is at end of the file. |
fread | (file, seq<T> dst) : u32 [impure] | Read data from file by overwriting elements. Return value is the number of read elements, but at most seqlen(dst). T can be: i8, u8 |
freadchar | (file) : char [impure] | Read a character from the file. |
freadbool | (file) : bool [impure] | Read a boolean from the file. |
freadstr | (file) : string [impure] | Read a zero-terminated string from the file. |
freadstr | (file, char) : string [impure] | Read string from the file until the given character. The separator is not part of the result. |
freadln | (file) : string [impure] | Read a line from the file. |
freadi8 | (file) : i8 [impure] | Read an i8 from the file. |
freadu8 | (file) : u8 [impure] | Read an u8 from the file. |
freadi16 | (file) : i16 [impure] | Read an i16 from the file. |
freadu16 | (file) : u16 [impure] | Read an u16 from the file. |
freadi32 | (file) : i32 [impure] | Read an i32 from the file. |
freadu32 | (file) : u32 [impure] | Read an u32 from the file. |
freadi64 | (file) : i64 [impure] | Read an i64 from the file. |
freadu64 | (file) : u64 [impure] | Read an u64 from the file. |
freadf32 | (file) : f32 [impure] | Read an f32 from the file. |
freadf64 | (file) : f64 [impure] | Read an f64 from the file. |
fwriteln | (file, string) [impure] | Write a line into the file. |
fwrite | (file, string) [impure] | Write a zero-terminate string into the file. |
fwrite | (file, T) [impure] | Write a T into the file. T can be: char, bool, string, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, seq<i8>, seq<u8> |
opendir | (string) : dir [impure] | Open a directory iterator for the specified directory. |
readdir | (dir) : bool [impure] | Read the next directory entry. Return false when the iteration is over. |
dirgetname | (dir) : string [impure] | Return the name of the current entry. |
dirgetmtime | (dir) : u32, u32, u32, u32, u32, u32 [impure] | Return the last modification date of the current entry (year, month, day, hour, minutes, seconds). |
dirgetsize | (dir) : u64 [impure] | Return the size of the current entry (0ul for directories). |
dirgettype | (dir) : char [impure] | Return the type of the current entry ('D' for directories, 'F' for files). |
islittleendian | () : bool | Return a boolean which indicates whether the current system is little endian. |
isbigendian | () : bool | Return a boolean which indicates whether the current system is big endian. |
ltob | (T) : T | Convert a value from little endian to big endian. T can be: i16, u16, i32, u32, i64, u64, f32, f64. |
btol | (T) : T | Convert a value from big endian to little endian. T can be: i16, u16, i32, u32, i64, u64, f32, f64. |
ltoh | (T) : T | Convert a value from little endian to host byte order. T can be: i16, u16, i32, u32, i64, u64, f32, f64. |
htol | (T) : T | Convert a value from host byte order to little endian. T can be: i16, u16, i32, u32, i64, u64, f32, f64. |
btoh | (T) : T | Convert a value from big endian to host byte order. T can be: i16, u16, i32, u32, i64, u64, f32, f64. |
htob | (T) : T | Convert a value from host byte order to big endian. T can be: i16, u16, i32, u32, i64, u64, f32, f64. |
rand | () : u32 [impure] | Return a pseudorandom integer in complete range of the u32 type. |
randf | () : f32 [impure] | Return a pseudorandom 32-bit floating point number from the [0,1] range. |
srand | (u32) [impure] | Seed the pseudorandom number generator. |
Name | Signature | Description |
---|---|---|
version | () : u32 | Returns the version of the Welltype environment. Value: 0x929 (hexadecimal) |