#MaxInt31 = 2'147'483'647 #MaxInt32 = 4'294'967'295 #MaxInt63 = 9'223'372'036'854'775'807 #MaxInt64 = 18'446'744'073'709'551'615 #Pi = 3.141'592'653'589'793'238'46 #E = 2.718'281'828'459'045'235'36 #Whitespace = ' &tab;&nl;&cr;' #ASCIIupperLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' #ASCIIlowerLetters = 'abcdefghijklmnopqrstuvwxyz' #ASCIIletters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' #DecimalDigits = '0123456789' #HexDigits = '01234567890abcdefABCDEF'
print a dump of all used items to stderr (if debug enabled)
Supply the number of elements (row, map, tuple), bytes (chunk), characters (code points, string). Same as attribute .Count Usful e.g. as (count of num _ '') to give the number of digits
Supply the number of bytes used Not required for expressions, use attribute .Bytes
Absolute value of a number
Alias for 'math abs ()'
Sign of a number
Alias for 'math sign ()'
Is string a raw string
Alias for 'string () is raw'
Is string an ASCII string
Alias for 'string () is ascii'
Last key of a row; same as .last
First key of a row; same as .first
True if item is a fault item
Increase acknowledge count of an error item. Same as x:checked =+ 1
Alias for: fault (item) mark checked
Alias for: fault (item) mark checked
Set tag attribute Not required for expressions, set control field .Tag
Increase the lock count of a row or map. When the lock count is not zero, the item becomes temporarily immutable.
Decrease the lock count of a row or map. If the lock count is still not zero, the item is still immutable. If the lock count was zero, it is not changed, but a fault item returned.
Set byte order attribute in chunks
check if void; same as x = ()
check if boolean; same as x .= ?- or x.kind = 'boolean'
check if integer; same as x .= 0 or x.kind = 'integer'
check if rational; same as x .= 1/2 or x.kind = 'rational'
check if float; same as x .= 0.0 or x.kind = 'float'
check if number; same as (x .= 0 | x .= 1/2 | x .= 0.0)
check if string; same as x .= '' or x.kind = 'string'
check if row; same as x .= [] or x.kind = 'row'
check if map; same as x .= {} or x.kind = 'map'
check if chunk; same as x.kind = 'chunk'
check if function; same as x.kind = 'function'
check if tuple; same as x.kind = 'tuple'
Test if integer is odd. Returns boolean, not integer (use x %% 2 to obtain an integer)
Test the n-th bit of an integer number. Negative targets are tolerated and treated as in two's complement, even for big integers. Returns boolean, not integer (use (x // 2^n) %% 2 to obtain an integer)
new empty row factory function Should never fail with a fatal runtime error. See: new row size ()
new row factory function Create a new row with minimum number of pre-allocated cells. A fault item may be returned on failure. Note that many operating systems use optimistic allocation and may return success, but kill the process later if memory is really exhausted.
Scan gives keys of non-void row elements The row may be modified or even another one while scanned; just the keys are enumerated and void cells skipped. Elements added during the scan at the upper end (high keys) are found, those at the lower end (low keys) not. To deliver all keys, use: from row.first upto row.last
Alias for 'row (row) give keys'
Alias for 'row (row) give keys'
Scan gives values of a row (ascending keys) Void entries are not supplied.
Sort the values in a row (vector) using the C library routine. If the compare funtion (func) is void, the TUF operator '>' is used for ascending numbers or strings. Otherwise it must be a function reference that returns an integer: > 0 for a > b = 0 for a = b < 0 for a < b Invert the sign for descending sort. Sort may be unstable, i.e. changing the order of equal items; for a stable sort use 'row (row) sort ascending using (func)' The row reference is returned in case the argument is from a function. The indices remain, i.e. .last and .first are unchanged, just the values are in given order.
Alias for: row (row) sort fast using ()
Sort the values of a row ascending using the C library routine. Shortcut for 'row (row) sort fast using ()'
Sort the values of a row descending using the C library routine.
Alias for: row (row) sort fast ascending
Alias for: row (row) sort fast descending
Sort a row (vector) in place for ascending values. If the compare funtion (func) is void, the standard TUF operator '>' is used, must be applicable for all values and gives ascending values. Otherwise, it must be a function reference that returns an integer > 0 for a > b = 0 for a = b < 0 for a < b Invert the sign for descending. Method used is in-place insert sort, which has low overhead for small sets and moderate speed for larger sets, and is stable, i.e. keeps the order of equal elements. For large sets (>10000) use e.g. row (row) sort fast using (func). The row reference is returned in case the argument is from a function.
Alias for: row (row) sort using (func)
Sort a row (vector) ascending. Shortcut for: row (row) sort using ()
Alias for: row (row) sort ascending
Sort a row (vector) descending. See 'row (row) sort using (func)' but using '<' instead of '>'
Alias for: row (row) sort descending
Sort a row (vector), and keep a second row (val) synchronous. Avoids the creation of a row of pairs to be sorted. Uses insert sort and might be slower than using fast sort with pairs. See "row (row) sort using (func)"
Alias for: row (row) sort sync (val) using (func)
Shortcut for: row (row) sort sync (val) using ()
Alias for: row (row) sort sync (val) ascending
Shortcut for: row (row) sort sync (val) using () but with inverted compare
Alias for: row (row) sort sync (val) descending
Quickly add element to a map allowing duplicates. The element is added without searching for the key, hiding, but not removing any previously set value. If the value is void, the most recent one is deleted, as with the ordinay map access. Improper use of this function may degrade performance.
Provide the keys of a map as a row in undefined order. May supply keys more than once on maps where .UniqueKeys is off To have the keys sorted, use e.g. row (map this keys as row) sort fast ascending
Alias of: map () keys as row
Provide the values of a map as a row in undefined order. Values for duplicate keys are correspondingly duplicated. Functionally equivalent to: rv =: new row size this.count ?# key =: map this give keys rv[] =: this{key}
Alias of: map () values as row
Provide key-value-pairs of a map as a row in undefined order. Values for duplicate keys are correspondingly duplicated. Functionally equivalent to: rv =: new row size this.count ?# key =: map this give keys rv[] =: key, this{key}
Scan to provide the keys of a map in undefined order. The keys are saved at the first call, so it is equivalent to: mr =: map (m) keys as row ?# key =: row mr give values \ the row values are the map keys :> key May supply duplicate keys if 'map () key () add () unchecked' was used (.UniqueKeys is false), and keys for cells deleted meanwhile.
Deprecated alias for 'map () give keys'
Deprecated alias for 'map () give keys'
Map scan provides values unsorted. The set of keys is saved at start, and the values are taken from the actual map. Void values are skipped like in a row scan.
Map scan provides key-value pairs unsorted. The set of keys is saved at start, and the values are taken from the actual map. Void values are skipped like in a row scan.
Create a tuple dynamically and fill it with row elements, Void elements are retained to keep the set of keys
New tuple with all elements equal. If one with diferent values is needed, use: row (row) as tuple
Scann to provide keys of a tuple (ascending) In contrast to rows, all keys are returned, even if the value is void
Scan to provide values of a tuple in ascending index order. In contrast to rows, void values are not suppressed
Lazy scan that uses '{row, map, tuple} (rmt) give keys' by determining the kind on the fly
Alias for give keys (bunc)
Lazy scan that uses '{row, map, tuple} (rmt) give keys' by determining the kind on the fly
Lazy scan that uses '{row, map, tuple} (rmt) give values' by determining the kind on the fly No fault, only void return if neither row, map or tuple
Alias for give values (bunch)
Truncate floating point to nearest integer (.int)
Truncate floating point to nearest integer (.int)
Deprecated for 'math trunc ()'
Round floating pointto nearest integer (.round)
Deprecated for 'math round ()'
Smallest integer greater or equal (.ceil)
Deprecated for 'math ceil ()'
Largest integer less or equal (.floor)
Deprecated for 'math floor ()'
Convert accurate (integer or rational) to approximate (floating point) number. Same as .float attribute or ## operator. Returns a copy if already a float. Returns 0.0 if void. No runtime errors, just void if not a number. Note that void is treated as zero in additions, not in mulitplications
Deprecated for 'math float ()'
Spawn a process, i.e. create a new process called child process. Returns the integer 0 within the child process, and the process id in the parent process.
Wait for state changes in a child of the calling process, i.e. wait for any child to die, and return the process id of that child.
get my process id
Kill process with number 'pn', using signal 'signo', given as integer. See 'man 7 signal'.
Kill process with number 'pn', using singal SIGTERM.
Create a map that maps all fields. If the argument is not a row, map, fault item or chunk, void is returned, not a fault item. May be used in conjuntion with 'set fields to transfer fields.
Alias for: bunch (bunch) get fields
Change the fields of a bunch with the values given in an map. The keys must be words, returns fault item if not; otherwise void is returned, not the bunch reference. Attempts to set attributes are silently ignored. TODO: ignore known control fields, or all that begin with capitals
Alias for: bunch (bunch) set fields (map)
call function (func) with one parameter return void if func is void
call function (func) with two parameters return void if func is void
call function (func) with three parameters return void if func is void
call function (func) with one parameter return void if func is void
call function (func) with two parameters return void if func is void
call function (func) with three parameters return void if func is void
Stop the programme immediately and exit to the caller. No internal cleanup is done, in particular no check for memory leaks. Graceful exit with check is done via return of the main function.
Create a fault item .errmsg and .errcode are parameters .errinfo is not yet set Fault items do not have attributes, just fields.
Alias for: new fault code (code) message (msg)
Dump information for item to standard error, if debug output is enabled
information on item without full tree dump if debug output is enabled
Enable runtime report
Disable runtime report
Enable debug output
Disable debug output
Check if debug is enabled
Set a certain locale to a value given a string. Locales to set are: ALL, COLLATE, CTYPE, MESSAGES, MONETARY, NUMERIC, TIME
Set locale as given in the environment variables. If not called, the locale will be 'C', i.e. not automatically used.
Obtain current locale string
Obtain current locale numeric formatting informaton Returns a map with the fields: .dpoint string between unit digis and fractional digits .groupsep string to insert before each group of digits Not yet: .grouping tuple of integer for the number of digits per group
Get the environment, i.e. the shell variables, and return a map of variable names and (string) values.
Get the current time as seconds since the epoch, i.e. since 1970-01-01 00:00:00 +0000 (UTC) Its purpose is to provide consistent time stamps, so leap seconds are ignored and all years divisible by 4 are leap years.
Alias for: system epoch seconds
Deliver local time and date as fields of a map res: res.sec seconds 0..60 (60 for leap seconds) res.min minutes 0..59 res.hour hours 0..23 res.day day of the month 1..31 res.month month 1..12 res.year year > 1970 res.wday day of the week 1..6 (monday = 1) res.yday day in the year 1..365 (1 jan = 1) res.isDST is daylight saving time res.offUTC seconds east of UTC res.timezone timezone abbreviation (string)
Deliver UTC time and date as fields of a map res, fields see localized version
Provide formatting of a time stamp localized. Formatting is done using the 'strftime' function; see its manual page for format codes. The result must not execeed 200 characters (bytes). The format must be an ASCII string, as multibyte characters could contain the conversion byte '%'. If the size of the buffer is exceeded, the empty string is returned (due to strftime interface), which may also be the case for some format codes.
Get the cpu-time used so far in seconds as a floating point number It might overflow (cross zero) on e.g. 72 minutes, and does not start at zero For detailled times, use 'system cpu times'
Alias for: system cpu seconds
Get the cpu-times used so far in seconds as a floating point number Returns a map with the fields: .utime user time for current process (whithout chlildren) .stime system time as above .cutime sums of .utime values for the current and all terminated children .sutime same as above for .stime For detailled times, use 'system cpu times'
Suspend execution for a given interval given in seconds May use float to sleep for microsencod upto 1 second Use sparingly, only if there is no wait for an event possible
Alias for: sleep (seconds) seconds
Sets the seed for 'random next integer' simple pseudo random number generator If the argument is void, the current time in seconds is used
Supply another simple pseudo random integer Range is 0 to $SYSTEM.randmax (both inclusive)
Set integer grouping character when numbers are converted to a string May be set to the (initial) void.
Set the string localization map The previous one is returned.
Check if a string is ASCII. Re-scan the string and set in particular the .isascii attribute As strings are immutable, a copy is returned if .isascii is changed, orignal returned otherwise (including void)
Copy the part of the string 'src' from 'first' upto 'length' characters. 'first' may be less than zero to denote counting from the end (-1 is the last character, i.e. 'src.count'). If 'first' is zero, a fatal runtime error is caused. If 'len' is zero or negative, the empty string is returned. Attempts to exceed the string limits are silently truncated. If 'src' is an empty string, the empty string is returned; If 'src' is void, void is returned. If the whole string is selected, it is not copied, but the reference returned instead.
Alias for 'string (src) from (first) length (len)
Alias for 'string (src) clip from (first) length (len)
Copy the part of the string 'src' from 'first' to 'last'. 'first' and 'last' may be less than zero to denote counting from the end (-1 is the last character, i.e. at 'src.count'). If 'first' is zero, the empty string is returned. If 'last' is zero, the whole string is returned. Attempts to exceed the string limits are silently truncated. If 'src' is an empty string, the empty string is returned; If 'src' is void, void is returned.
Alias for 'string (src) from (first) upto (last)
Alias for 'string (src) from (first) upto (last)
Copy the part of the string 'src' that starts at 'first' upto the end. Equivalent to 'string (src) clip from (first) upto (src.count)'
Alias for 'string (src) from (first)'
Alias for 'string (src) from (first)'
Copy the part of the string 'src' upto the 'last' character. Equivalent to 'string (src) clip from (1) upto (last)'
Alias for 'string (src) upto (last)
Alias for 'string (src) clip from (first) upto (last)
In string 'str', locate the string 'needle'. On success, return the start position. On failure, return integer zero. If 'needle' is the empty string, the result is 1. If 'needle' is void, the result is 0 If 'str' is void, the result is void.
In string 'str', locate the string 'needle', starting at 'start'. Start may be negative and then counts from the end (-1 is the last character), but may neither be 0 nor void. On success, return the start position, which may be negative. On failure, return integer zero. If 'needle' is the empty string, the result is 1. If 'needle' is void, the result is 0. If 'str' is void, the result is void.
Concatenate string 'str' for 'ni' times, without delimiters. If the source string is empty, or the count (ni) is zero or void, the target string is the empty string. The source must be a string, and cannot be void.
Convert 'str' to an integer number detremined by 'base' using the existing library function 'strtol'. String 'str' may begin with an arbitrary amount of white space, followed by a single optional '+' or '-' sign. If base is void or 0, the base is determined by a prefix (after a sign): If it is '0x' or '0X', the base is 16; if it is 0, the base is 8. Otherwise, the default base is 10. If the base is 16, a prefix of '0x' or '0X' is optional. In bases above 10, the letter 'A' in either upper- or lowercase represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. Using bases above 36 is not recommended, although it may work. See 'string (str) as integer base (basespec)' as alternative. Deviating from 'strtol', the string may not contain arbitrary characters after a valid number, only white space, otherwise a fault item is returned. An empty string returns integer 0. Void returns void for easier map handling. See also 'string (str) as integer base (basespec)'. Arbitrary precision integers are supported.
Alias for: string (str) as integer clib (base)
Alias for: string (str) as integer clib (0) i.e. using C conventions
Alias for: string (str) as integer clib (0) i.e. using C conventions
Convert the string 'str' to a rounded (floating point) number. using 'strtod', which besides decimal numbers like '3.5E-9' also allows hexadecimal number like '0x123P3' for 123*2^3. Only blanks may enclose the number. Returns fault item on error. Return void from void as with integers.
Alias for: string (str) as float
Alias for: string (str) as float
Alias for: string (str) as float
Alias for: string (str) as float
Format a single number using C library '(s)printf' formats, see its manual page for format codes. First parameter (format) is the format string, second an integer or a float. Integers are 64-bit, i.e. long long int, thus use "%lld". Floats are double. The format string is not checked and must be ASCII only. It must produce less than 333 characters, or a fault item is returned. (The format '%.16f' for the maximum number 1E308 produces 324 digits.) Neither rationals nor arbitrary precision (big) numbers can be used. A void argument returns void.
Alias for: cformat (format) (num)
Alias for: cformat (format) number (num)
Alias for: cformat (format) number (num)
Returns a (decimal) string converted from a float. Floating point numbers are shown with upto 6 decimal places or in exponential form, similar to %G by printf, but with always a decimal point and at least one digit behind. This is the same format used for combining strings with numbers.
Returns a (decimal) string converted from any kind of number. For integers, just the digits (and a leading minus) are given; for rationals, two numbers separated by a slash (e.g. -3/4). Floating point numbers are shown with upto 6 decimal places or in exponential form, similar to %G by printf, but with always a decimal point and at least one digit behind. This is the same format used for combining strings with numbers. The result is groupd by decimal digits by the function Void returns void, and any other kind a fault item; this may make map handling easier.
Alias for: number (num) as string
Alias for: number (num) as string
returns a boolean as string '?+' or '?-' Void returns void for easier map handling.
Alias for 'boolean (b) as string'
convert a character code (code point in Unicode terminology) to a one-character length string. The code point must be a non-negative number in the range of Unicode code points.
Give the integer character code (code point in Unicode terminology) of the character at 'pos' in string 'str', 1 is the first character. If 'pos' is less zero, it is counted from the end, -1 is the last character. If 'pos' is zero or beyond the size of the string, null is returned, as integer 0 is a valid code point.
Tests the first character in string (str) for upper case. Returns ?+ if it is upper case (not the negation of lower case). return ?- if not or empty string. Void is returned as void. Is not the negation of lower case test. Call 'system set locale' to check for non-ASCII characters
Tests the first character in string (str) for lower case. Returns ?+ if it is lower case (not the negation of upper case). return ?- if not or empty string. Void is returned as void. Call 'system set locale' to check for non-ASCII characters
Convert string characters to upper case Void is returned void, empty string unchanged Call 'set locale' to convert non-ASCII characters
Convert string characters to lower case Void is returned void, empty string unchanged Call 'set locale' to convert non-ASCII characters
Hash function for strings returns an (32bit) integer number calculated iteratively by sum =: sum * 19 + byte[i] mod 2^31 where byte[i] is the i-th byte (not code point) and the sum starts with the number of bytes.
replace all occurences of %xx with single bytes, as is used for HTML query strings including UTF-8 encoded characters. Replacement of '+' by space is not done. The result is marked as ASCII or RAW, unless it is valid UTF-8. Input markings of ACSCII and RAW are ignored, and UTF-8 strings are treated bytewise, not characterwise. E.g. "a%DCöx" is very dubious, but allowed by the standard, and result in a string with the .raw attribute set. Note that %25 results in a '#' character in the output. If '#' is not followed by two hex digits, it is copied to the output and scanning continues with the next character. Normally, input should only be strings with the .ascii atribute set. Newline characters are silently ignored and not copied.
print an item in default format to standard output, without trailing line feed If output is a terminal, stdout is flushed
print an item in default format to standard output, without trailing line feed Deprecated, use print (mixed) nonl
print item in default format to standard output, followed by a line feed. If output is a terminal, stdout is flushed
print an item in default format to standard error, without trailing line feed Stream stderr is flushed even if not a terminal
print item in default format to standard error, followed by a line feed. Stream stderr is flushed even if not a terminal
Print argument without linefeed to standard error if the global DEBUG flag is set.
Print argument and linefeed to standard error if the global DEBUG flag is set.
Print source linenumber and argument to standard error if the global DEBUG flag is set. Same as: debug print '@&lineno;:', _ mixed'
Print source position and argument to standard error if the global DEBUG flag is set. Same as: debug print '&filename;@&lineno;:', _ mixed'
print the current function call stack to stderr (depth) may be void or zero for no limitation, or a non-zero integer to limit the number of entries.
Alias for: debug print calls (depth)
file handle for the standard input stream
file handle for the standard output stream
file handle for the standard error stream
Open a file for linewise access Mode indicators are: 'r' reading only, file must exist 'r+' reading and writing, file must exist 'w' writing only, truncated or newly created 'w+' reading and writing; truncated or newly created 'a' appending only; empty file created if not existiing 'a+' reading and writing, position to end initially, created if not existing On error, a fault item is returned with .errno the system error integer number .msg the corresponding string .info not set
Open a file for linewise reading only. The file must already exist. Reading starts at the first byte. Same as mode 'r'
Open a file for linewise reading and writing. The file must already exist. There is one common file position, that is advanced by both, reading and writing. Same as mode 'r+'
Open a file for linewise writing only. Truncated if it exists, created otherwise. Same as mode 'w'
Open a file for linewise reading and writing. Truncated if it exists, created otherwise. Starts at the beginning of the file. Same as mode 'w+'
Open a file for append writing only Created if the file does not exist. Any write appends data to the current end of the file. Same as mode 'a'
Open a file for linewise reading and appending Reading starts at the first byte and advances the position, but any write appends data to the end of the file, leaving the position after the last byte written. If the file does not exist, it is created. Same as mode 'a+'
Drops, i.e. closes, a file stream. Although streams are closed automatically when the item is discarded, errors can only be captured with a explicit close, otherwise they are a fatal runtime error. Returns the null reference on success. If an error occured, a fault item is returned.
Flushes a file stream, i.e. drains internal buffers so that the data is available for other processes Avoid flushing of read-only streams Returns null or a fault item.
Returns an integer giving the current file position, which is a byte number. Note that unless the stream is read as raw strings, this number may be larger than the number of characters if UTF-8 encoded bytes are present. a fault item is returned if the stream is not seekable, e.g. a pipe or standard input from a terminal.
sets the current file position of 'stream' to byte number 'loc', counted from the beginning. Note that for UNIX file semantics, positioning behind the end is possible and extends the file. a fault item is returned if the stream is not seekable, e.g. a pipe or standard input from a terminal.
Returns the next line from 'stream' as a string. Line delimiters are linefeed characters. The line is always scanned and marked as RAW, ASCII or UTF-8. If the file is at its end, null is returned. The delimiting line feed character is **not** part of the returned string, and any trailing carriage return character is also removed. Thus, using this interface, there is no difference whether the last character of a (text) file is a linefeed or not. Note that UNIX streams use zero-terminated strings, thus no zero byte will ever be part of the string. If such a stream read is too restrictive, use the basic unbuffered I/O (read and write).
Writes the contents of the string 'line' to 'stream', followed by a line feed character. Thus, using this interface, there is no way to write a text file that has not a line feed as last character. If the string contains line feed characters, these are not removed, even if this may be (ab-) used to write more than one line in a single call. Also, trailing carriage returns are not removed, but do not show if the file read in later as a stream. Consequently, no partial lines can be written. Note that UNIX streams use zero-terminate strings, thus if the string contains zero bytes, it will be truncated there. Return is always a null reference, unless an error occured, and a fault item is returned. If such a stream write is too restrictive, use the basic unbuffered I/O.
Appends the string 'line' atomcially to 'stream'. The stream must be opended in append mode. The intended use is to use the buffered stream for reading only, and append only with this function, even if buffers are flushed before the write. The stream is positioned then to current end of the file, i.e. somewhere behind the data written. Returns null if the write succeeds, and a fault item otherwise.
Created a command pipe (command) and a stream to read the command output. If the environment variable 'TUFPL_NO_SHELL' is set, this is a fatal error.
Created a command pipe (command) and a stream to write the command input, which normally will redirect its output to some file. If the environment variable 'TUFPL_NO_SHELL' is set, this is a fatal error.
Drops, i.e. closes, the stream. Although streams are closed automatically when the item is discarded, errors can only be captured with a explicit close. If an error occured, a fault item is returned. In order to avoid accidential loss of return codes, if the return code of the command is not zero, a fault item is returned too.
Return the next line from a command stream
Writes the contents of a string to the given command (pipe) stream, followed by a line feed character. Return is always a null reference, unless an error occured, and a fault item is returned.
Returns the attributs of a filename or open file stream as a map with zero elements with user attributes: The attribute 'ftype' returns a string, e.g.: file, dir, cdev, bdev, fifo, socket Integer valued attribs are: inode, mode, links, uid, gid, size, atime, mtime, ctime, space Boolean attribute: symlink, directory If the file does not exist, a fault item is returned. The 'space' attribute gives the number of bytes allocated, if this is less than 'size', the file is sparse. The file item may be a string as a file name, or an open stream, or an open chunk handle. Note that symlinks are followed, so the information is that of the file; however, this fact is signalled by the .symlink attribute to be true. Information about the symlink itself cannot be obtained by this function. The symlink attribute is also set if error code 2 is returned, meaning that the symlink refers to file that no longer exists; in this case, the error message is changed from 'No such file or directory' to 'Symbolic link invalid'. If the handle for an open file is used, the filename cannot be obtained, as the number of filenames in directories can be from zero to many any time after the file has been opened. So it is not supplied for requests with a filename string. Note that the access time '.atime' may be stale, if the filesystem is mounted with the 'relatime' option, that updates the atime only once within 24 hours, or if it is smaller than the others, avoiding disk writes if files are only read.
get value of extended file attribute (user space) returns null if not set, a string, or a fault item currently, the result is truncated to 1023 bytes, if longer
set value of extended file attribute (user space) returns null, or a fault item if the value is null, the attribute is removed removing a non-existent attribute is not an error
Creates a stream to read directory entries line by line.
Drop (close) a running directory stream
Returns the next filename from a directory stream, (in directory order).
Create a file (hard) link returns null reference if ok, fault item otherwise
Create a file symbolic link returns null reference if ok, fault item otherwise
Creates a directory using a path. returns null reference if ok, fault item otherwise
Unlinks a filename, i.e. deletes it from its directory, which deletes the file if it has no more references returns null reference if ok, fault item otherwise
Determine canoncial absoulute pathename ('realname')
Get current (working) directory
check if a stream is connected to a Terminal Argument is e.g. 'system standard output' Returns ?+ if it is, ?- if not, fault item else
Deprecated to check if a standard input is a terminal; use 'file stream system standard input is tty' instead
Deprecated to check if a standard output is a terminal use 'file stream system standard output is tty'
Check if string matches shell wildcard pattern Backslashes are matched verbatim (not used as escape character) Leading periods are not matched by * or ? returns boolean true or false
open a file for unbuffered binary chunk reading and writing. If the file does not yet exist, it is created, and permissions are then set all minus umask, valid for future opens only. If the file does exist, but without write permission, a fault item is returned.
open a file for binary chunk reading. No write permission is required on the file. If the file does not exist, a fault item will be returned.
open a file for binary chunk reading and writing. Write permission is required. If the file does not exist, or has no write permission, a fault item will be returned.
open a file for binary chunk, reading and appending. Each write is preceeded by setting the file position to the end of the file, and then the buffer is written, both atomically, if it's a local file system. To re-read the written data, the position has to be set back to where it was before the write. Setting the position immediately before a write has no effect. If the file does not exist, a fault item will be returned.
Drops, i.e. closes, a binary file IO Although files are closed automatically when the item is discarded, errors can only be captured with a explicit close, otherwise they are a fatal runtime error. Returns the null reference on success. If an error occured, a fault item is returned.
Read a binary chunk from a file returns the number of bytes read and changed in the chunk
write a binary chunk to a file If the file was opened for append, the file offset is first set to the end of the file before writing, both atomically.
Obtain current position of a chunked file. Returns an integer which is the zero based byte offset in the file
Position a chunked file relative to the start 'dist' must not be negative. Void is treated as 0. Note: If the resultant position is beyond the current end, no error is returned, but the space logically allocated to zero bytes. Returns the new position relative to the start.
Position a chunked file relative to the current position. 'dist' may be negative. Void is treated as 0. Note: If the resultant position is beyond the current end, no error is returned, but the space logically allocated to zero bytes. Returns the new position relative to the start.
Position a chunked file relative to the current end. 'dist' is often negative. Void is treated as 0. Note: If the resultant position is beyond the current end (i.e. 'dist' is positive), no error is returned, but the space logically allocated to zero bytes. Returns the new position relative to the start.
Create a unidirectional pipe for interprocess I/O A single pipe descriptor (system item) is returned, that can be read or written to. Normally, after the creation the process is forked in one reading and one writing, the reading one closing the pipe for writing, the writing one closing the pipe for reading. Otherwise the process may block. Note that the UNIX system creates two file descriptors, that are both handled in the system item (pipe descriptor) Preliminary version with standard buffer length 4096 and no logical buffering.
Close the reading end of a basic pipe
Close the writing end of a basic pipe
Receive bytes at the reading end of a basic pipe as string. A byte string of no more than 4096 bytes is read and delivered as a string without ISO conversion, but with UTF-8 and raw check. The read blocks until data is available from the write end. Returns void if the write counterpart is closed (end-of-file).
Sends a string to the reading end of a basic pipe. If the string could not be fully delivered in one action, a fault item is returned, and the number of bytes (not characters) given as string in the .info field; note that in this case, the UTF-8 encoding for the last character may be invalid on the receiving side. Returns void on success.
Calculate the sinus of an approximate (floating point) number
Calculate the inverse sinus of an approximate (floating point) number
Calculate the cosinus of an approximate (floating point) number
Calculate the inverse cosinus of an approximate (floating point) number
Calculate the tanges of an approximate (floating point) number
Calculate the inverse tangens of an approximate (floating point) number
Calculate the arc tangent function of two floats, i.e. i.e. the principal value of the arc tangent of y/x, using the signs of the two arguments to determine the quadrant of the result. see man 3 atan2
Calculate the square root of an approximate (floating point) number
Calculate an approximate (floating point) number to the power of e
Calculate an approximate (floating point) base to the power of any (floating point) exponent same as base^exponent, restricted to floating point numbers
Calculate the natural logarithm (to the base e)
Calculate the logarithm to the base 10
Calculate the logarithm to any base, which is (math log arg) / (math log base)
Determine the size in (base) digits required to represent (arg), either exact or +1, i.e. the number of digits required (without sign). E.g. for base 2, ld(2) = 1, ld(3)=2, ld(1023)=10, ld(1024)=11 As a convenience, ld(0) = 0 If (base) is void, 10 is assumed. if (arg) is void, 0 is returned independent of base. Basically the same as 'count integer arg as string base base'
Integer square root (arbitrary precision) Largest integer when squared does not exceed the argument See 'is () square' how to test for a perfect square
Create new byte chunk of given size (in bytes) If there is no space, a fault item is returned
Zero a chunk slice The size must be positive, and offset and size are adjusted if out of range. Returns the offset of the next byte behind the filled area. .lock, .shut are honored, and .revs is incremented.
Zero a chunk slice shortcut for 'zero chunk (chnk) at (offset) size chnk.bytes
Zero a chunk slice shortcut for 'zero chunk (chnk) at 0 size chnk.bytes
Create a copy of a byte chunk slice: A new chunk of the size given is created, and filled from the slice. The offset may be negative and is then counted from the end. The size given must be positive and determines the size of the new chunk. If the offset exceeds the filled area, nothing is copied, just the new chunk created uninitialized. If there are less bytes at the offset than the size, only these are copied, and the new chunk partially filled. The byte order attribute is propagated. If there is no space for the new bunch, a fault item is returned.
Extract integer from byte chunk. The source bytes are given by an offset (zero based) and a size; this must be fully within the chunk to avoid data corruption. The result is always signed; to obtain the unsigned equivalent, add 2^8=256, 256^2=65536, 256^3=16´777´216 etc. if negative. If more than one byte is fetched, a byte order must be set for the chunk.
Extract string from a chunk slice. The position may be negative, and is then counted from the end. The size must not be negative, and is adjusted so that the slice lies in the filled space. If may become zero; then an empty string is returned. The resulting string is checked for UTF-8, but currently no autoconversion is implemented. If the source is UTF-8 and a wrong size used, the resulting string may be truncated inside an encoding and thus flagged '.raw'.
Extract string from chunk and stop if a zero byte is found. The position may be negative, and is then counted from the end. The size must not be negative, and is adjusted so that the slice lies in the filled space. If may become zero; then an empty string is returned. The resulting string is checked for UTF-8, but currently no autoconversion is implemented. If the source is UTF-8 and a wrong size used, the resulting string may be truncated inside an encoding and thus flagged '.raw'.
Extract string from chunk and stop if a linefeed is found. The position may be negative, and is then counted from the end. The size must not be negative, and is adjusted so that the slice lies in the filled space. If may become zero; then an empty string is returned. If no linefeed is found, null is returned, even if there are characters left. The resulting string is checked for UTF-8, but currently no autoconversion is implemented. If the source is UTF-8 and a wrong size used, the resulting string may be truncated inside an encoding and thus flagged '.raw'.
Extract string from chunk and stop if a given character is found. The position may be negative, and is then counted from the end. The size must not be negative, and is adjusted so that the slice lies in the filled space. If may become zero; then an empty string is returned. The resulting string is checked for UTF-8, but currently no autoconversion is implemented. If the source is UTF-8 and a wrong size used, the resulting string may be truncated inside an encoding and thus flagged '.raw'.
Replace a chunk slice by a string. The position may be negative and is counted from the end. The size must be at least the byte length of the string, and all bytes must fit into the chunk. If it is shorter, the remaining space is filled with zero bytes. If the offset is beyond the filled space, zero bytes are prepended. Returns the offset of the next byte behind the area written to. Attributes .lock, .shut are checked and .revs, .filled are set.
Replace a chunk slice with a binary integer. The position may be negative and is counted from the end. The size must be positive, and all bytes must fit into the chunk. If the offset is beyond the filled space, zero bytes are prepended. Returns the offset of the next byte behind the filled area. Attributes .lock, .shut are checked and .revs, .filled are set. Currently, only 1 to 8 bytes are supported.
Replace a chunk slice by a chunk slice The positions may be negative and are counted from the end. The target size must be at least the source size (no truncation). If it is larger, the remaining space is filled with zero bytes. If the target position is beyond the filled space, zero bytes are prepended. The chunks slices may overlap; in this case, it works like an extra buffer is used Returns the offset of the next byte behind the area written to. Attributes .lock, .shut are checked and .revs, .filled are set.
Wrap a function into a scan. Repeats until the value (val) is void or a fault item. Do not wrap a scan function.
Wrap a function into a scan. Repeats while the value (val) is an integer number unequal to zero. Do not wrap a scan function.
Wrap a function into a scan. Repeats while the value (val) is an integer less than zero Do not wrap a scan function.
Wrap a function into a scan. Repeats while the value (val) is an integer greater than zero Do not wrap a scan function.
Return the largest value of a tuple, row or map The values must be comparable by '<' If not a row, tuple or map, return the argument
Alias for: maximum of (vals)
Alias for: max of (vals)
Return the smallest value of a tuple, row or map The values must be comparable by '<' If not a row, tuple or map, return the argument
Alias for: minimum of (vals)
Alias for: minimum of (vals)
Generates integer numbers starting at (from) down to (last) At end, the next value, i.e. (last-1), is returned. The parameters must be integer numbers.
Generates integer numbers starting at (from) up to (last) At end, the next value, i.e. (last+1), is returned The parameters must be integer numbers.
Generates numbers starting at (first) up to (last) incremented by (step) The step value is added, thus it must be positive to ensure termination At end, the next value > (last) is returned Parameters must be either accurate (integer or rational) or approximate (float)
Generates numbers starting at (first) down to (last) decremented by (step) The step value is subtracted, thus it must be positive to ensure termination At end, the next value > (last) is returned Parameters must be either accurate (integer or rational) or approximate (float)
Generates numbers starting at (first) adding (step) Depending on the sign of (step), upto or downto (limit) is used. Step must not be zero to avoid endlessness. To be implemented in runtime system for loop context check and efficiency
Generate pairs, triples etc (start) and (last) must have the same number of elements from (1,2) upto (2,4) give tuples delivers in that order: (1,2) (2,2), (1,3), (2,3), (1,4), (2,4)
Create a tagged row. Shortcut for: rv =: new row rv.tag := tagname
Create a tagged row wit an initial size. Shortcut for: rv =: new row size int rv.tag := tagname
Copy a row's values, but not the fields The set of keys remains the same (no renumbering) else use e.g. tgt =: [src.count] ?# sv =: row src give values tgt[] =: sv
Create a row from another one including fields.
Create a row from a tuple
Shrink row, i.e. return a copy without void elements, renumbered If there are no void elements, the original is returned. The first index is the same, even if it had a void cell. Fields are preserved.
Copy row (row) starting with index (from) upto index (upto) There is no check that (from <= row.first) or (upto >= row.last); and all void elements are discarded, i.e. all non-void elements starting with (from) are copied from index 1 on to a new row, upto (upto) as last index processed.
Append a row, tuple or map to an existing row. The non-void elements of (rmt) are added at the end of (row).
Set duplicates void. To remove all duplicate values, the values must be sorted, as just the 2nd and all following references that are equal to the 1st are voided. Uses standard key scan, thus voids already there are ignored. Often used in the sequence row r sort fast ascending row r dedup row r shrink
Copy tuple (tup) starting with index (from) upto index (upto) There is no check that (from <= tup.first) or (upto >= tup.last); and all void elements are discarded, i.e. all non-void elements starting with (from) are copied from index 1 on to a new tup, upto (upto) as last index processed.
Provide the keys with not void values as a row
Provide the not void values as a row
Generalised check for an element within a set. If the key and the set are strings, check if the key is in the string (e.g. is str[i] in ##DecimalDigits) If the key is the empty string, returns true. Otherwise, the set must be a tuple, row or map, and the key searched in the values.
Shortcut for '~ is (key) in (set)'
Create a new map from a (sparse) row, using the integer keys, ignoring void cells.
Alias for: row (row) as map
Push a non-void value to a row used as stack As the '.count' attribute is used, values may not be void. To create a stack, just create a row and push the first value.
Pop the top value of a row used as stack. As void cannot be pushed, returns void if exhausted. see: row (row) push (val)
Create a tagged map, shortcut for: rv =: new map map.tag =: tagname Note that tags may be set only once.
Provide a row of key-value-pairs (unsorted) Implemented as: pairs =: new row size this.count ?# key =: map this give keys pairs[] =: key, this{key} :> pairs Sorting by key is simple due to the comparison rules for tuples: row (map this key value pairs as row) sort fast ascending
Provide a row of value-key-pairs (unsorted) Implemented as: pairs =: new row size this.count ?# key =: map this give keys pairs[] =:this{key}, key :> pairs Sorting by value is simple due to the comparison rules for tuples: row (map this value key pairs as row) sort fast ascending
Create a new map from a tuple of pairs, e.g. ('a', 1), ('b', 2), ... Duplicate keys overwrite the value.
Alias for: tuple (tup) as map by pairs
Add to a map from a row, map or tuple of pairs. Just a shortcut for: ?# lv =: give rmt values this{lv.1} =: lv.2
Copy a map efficiently. Fields are not copied (lean copy). If the source has duplicate keys (must be created intentionally), these are not preserved and the function may be slow.
Copy a map including fields efficiently. Uses 'map () copy lean'.
Provide a map of those keys that are not unique. Allows mixed kinds of keys, i.e. only equality comparison is used. If no such keys are found, void is returned, as is if .UniqueKeys is true on entry
Returns a string of key-value-pairs for a map The values must be plain, i.e. numbers or strings or booleans. Keys and values are joined using string (delim), default '=', pairs are connected by string (sep), default blank ' '. Both should be strings. If (qr) is a reference to a function (with one parameter), the return value is used, thus should be a string. If (qr) is a string, the function `string () wrap qr` is used. If (qr) is void, `quote ()` is used. Note that 'quote ()' and 'string () wrap ()' also quote numbers; use different quoting function if numbers shall be unquoted.
Read file (filename) as lines into a row If there is an error, the fault item received is returned unprocessed; just the row of lines read so far is saved in the .data attribute of the fault item
Alias for: file (filename) lines
Alias for: file (filename) lines
Generates the lines of the file (filename) as a scan. End-of-file is returned as void. If the filename is void, standard input is used. Fault items of lower level functions are given back as value. In order to avoid infinite loops, fault items are only returned once; the second call results in an assertion violation.
Alias for: file (filename) give lines
Generates the lines from standard input See 'file (filename) give lines'
Generates the lines from standard input See 'file (filename) give lines'
Give the filenames in directory (dir) in directory order. Returns a fault item if directory does not exist. To scan sorted, use dr =: sort directory dir filenames ?# fn =: row dr give values
Alias for: directory (dir) give filenames
Directory (dir) filenames unsorted as row. Returns a fault item if directory does not exist.
Alias for: directory (dir) files
Generate the resulting lines when executing the command string (cmd) by the shell. See 'quote (str) for shell' to protect special characters. Fault items are given back as value. In order to avoid infinite loops, fault items are only returned once; the second call results in an assertion violation. If the command string contains newline characters, the shell may execute more than one command.
Alias for: command string (cmd) give lines Put the variablle in parenthesis if not found: stream =: 'uname -a' ?# line =: command (stream) give lines
Alias for: command (cmd) give lines
Execute string (cmd) via the shell, collect the output lines in a row and return this row If an error occurs, the lines obtained so far are in the '.data' attribute of the fault item. If the string contains newlines, the shell may execute more than one command.
Alias for: command string (cmd) lines Put the variablle in parenthesis if not found: stream =: 'uname -a' row =: command (stream) lines
Alias for: command (cmd) lines
Alias for: command (cmd) lines
Quote shell meta characters by backslash. The result is not to be enclosed in quotes.
Test if the character (c) is in string (str). Obsolete wrapper for: string (str) locate (c) Intended for optimisation if c is a single character
Alias for: string (str) has character (c)
Alias for: string (str) has character (c)
Count in string (str) from (start) the characters found in (accept). If none is found, or (start) is behind the end, then 0 is returned. Negativ (start) counts from the end (-1 is last). Zero (start) is an error.
Count in string (str) from (start) the characters not in (reject). If none is found, or (start) is behind the end, then 0 is returned. Negativ (start) counts from the end (-1 is last). Zero (start) is an error.
Clip in string (str) from (start) the longest part with characters in (accept). If none is found, or 'start' is behind the end, the empty string is returned. Negativ (start) counts from the end (-1 is last). Zero (start) is an error.
Alias for 'string (str) from (start) many of (accept)'
Clip in string (str) from (start) the longest part with characters not in (reject). If none is found, or 'start' is behind the end, the empty string is returned. Negativ (start) counts from the end (-1 is last). Zero (start) is an error.
Alias for: string (src) clip from (start) none of (reject)
Give clips of string (str) separated by any single character in (seps). If two separators follow directly, an empty string is returned, also for leading and trailing separators. If (str) is the empty string, nothing is generated. See also 'string (str) give clips by many of (seps)'
Alias for: string (str) give clips by any (seps)
Give clips of string (str) separated by any combination of characters in (seps). An empty string is returned only if there is a leading or trailing separator character. If (str) is the empty string, nothing is generated. See also 'string (str) give clips by any of (seps)'
Alias for: string (str) give clips by many (seps)
Give clips of string (str) separated by strings (seps), which is either a tuple or row of strings, or a single string. If two separators follow directly, or are head or tail, an empty string is returned. If one delimiter is the prefix of another one, either may be used (not necessarily the longest one). No delimiter may be the empty string.
Split string (str) into an row of strings using any one of the characters in (seps) as separators. If two separators follow directly, or are leading or trailing, an empty string is provided (not a void). The empty string returns a row without elements Uses 'string str give clips by any of seps' to fill the row.
Split string (str) into an row of strings using any combination of the characters in (seps) as separators. If separators are leading or trailing, an empty string is provided (not a void). The empty string returns a row without elements Uses 'string str give clips by many of seps' to fill the row.
Split string (str) into an row of strings using any one of the strings in the tuple (seps) as separators. If two separators follow directly, an empty string is entered (not a void). The empty string returns a row without elements
Tell if string (str) at position (pos) has string (what) If (what) is a tuple of strings, each is probed, and the first match is a success. Wrapper around 'cue = string str from pos length cue.count'
Alias for: string (str) from (pos) has (key)
Check if string (str) starts with the string (head). (head) may be a tuple of strings; first match is a success Wrapper for:
Alias for: string (str) has head (head)
Alias for: string (str) has head (head)
Alias for: string (str) has head (head)
Check if string (str) ends with the string (tail). (tail) may be a tuple of strings; any match is a success
Alias for: has string (tail) tail (str)
Alias for: has string (tail) tail (str)
convert a string to a row of (single character) strings
Join cell values of row (row) to a string without separators. The cell values are in ascending order of the row keys. As string concatenation converts numbers, the cell values of the row may be strings or numbers or both. Void cell values are skipped.
Join cell values of row (row) to a string with separator (sep). The cell values are in ascending order of the row keys. As string concatenation converts numbers, the cell values of the row may be strings or numbers or both. Void cell values are skipped.
Join all keys (with nonvoid values) of row (row) to a string with separator (sep). The keys are in ascending order.
Catenate all values of a row, map or tuple with blank as separator. Values are converted to strings by the string catenation. See: join () by ()
Catenate all values of a row, map or tuple with (sep) as separator. Values are converted to strings by the string catenation. No individual versions for rows, tuples or maps necessary, as 'give () values' resolves it.
Join all keys (not values) of map (this) to a string, separated by (sep), in undefined order Use: join map map keys by sep
Join all values of map (this) to a string, separated by (sep). Standard scan is used, thus the order is undefined.
Remove from the beginning of the string (str) all characters that are in (chars), and return the resulting string.
Alias for: string (str) without leading (chars)
Remove all leading whitespace from a string. This is the same as string str without leading #Whitespace
Alias for: string (str) without leading whitespace
Remove from the end of the string (str) all characters that are in (chars), and return the resulting string.
Alias for: string (str) without trailing (chars)
Remove all trailing whitespace from a string. This is the same as string str without trailing #Whitespace
Alias for: string (str) without trailing whitespace
Pad the start of the string (str) by the character (chr) to the length (len). If its length already greater than (len), return unchanged.
Pad the string (str) at its end by the character (chr) to the length (len). If its length already greater than (len), return unchanged.
If the parameter (mixed) is a number, convert it to a string, then pad the start of the string (str) by the character (chr) to the length (len). If its length already greater than (len), return unchanged.
If the parameter (mixed) is a number, convert it to a string, then pad the start of the string (str) by blanks to the length (len). If its length already greater than (len), return unchanged.
If the parameter (mixed) is a number, convert it to a string, then pad the start of the string (str) by the character (chr) to the length (len). If its length already greater than (len), return unchanged.
If the parameter (mixed) is a number, convert it to a string, then pad the start of the string (str) by blanks to the length (len). If its length already greater than (len), return unchanged.
Alias for: pad left (str) to (len)
Alias for: pad right (str) to (len)
Put a string in Quotes. Quotes inside are escaped as '"', and '"' is replaced by '&quot;' before. Numbers instead of a string are converted to strings.
Alias for: string (string) quoted
Enclose (str) by (wrap) If (wrap) is a tuple, returns 'wrap.1 _ string _ wrap.2' If (wrap) is a string, any occurence of (wrap) inside is doubled. Use `string () quoted` for escaping by HTML entities. Numbers are automatically converted to strings and quoted too.
Convert integer (i) using arbitrary digit characters from (basespec). The number of characters in (basespec) determines the base:+ '012356789' is decimal '0123567' is octal, '0123456789ABCDEF' is hexadecimal, as is '0123456789abcdef' '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' is base 36 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' is base 62, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' is base 64 It is recommended to use ASCII 7 bit without controls, i.e. max. 96 characters, so that the code points are smaller than the basespec. If duplicate digits are present, the result is undefined. If the input number is negative, a '-' is prefixed. If 'basespec' is an integer instead of a string, it must be between 2 and 62 or 64. Unless 64, the above string for basespec 62 is used, otherwise the altenate string for basespec 64. If 'basespec' is void, 10 is used.
Convert a string (str) to an integer by (basespec) If (basespec) is an integer between 2 and 62, digits, capital letters and small letters are used (in this order); if it is 64, the characters are 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' To have hex digits with small letters, use '0123456789abcdef' If (basespec) is a string, its characaters are used as digit characters; the base is the number of characters. If (basespec) is void, decimal digits are used (base 10). Integer (basespec) may not be <2, 63 or > 64. String (basespec) may be of arbitray length; if there are duplicate characters, the result is undefined. In the input (str), a leading '-' is used as sign, so its use as a digit character is undefined. Blank space or any charcters in the input string that are not in the base string are not allowed, and a fault item is returned. Note that in contrast to the function 'string (str) as integer clib (base)': - 'basespec' may not be zero, and void means decimal only - prefixing '0x' or a leading zero does not indicate base 16 or 8
Integer conversion for strings with decimal digits. Alias for 'string str as integer base ()'
Alias for: string (str) as integer use 'as c integer (str)' if 0x and leading zeros should be possible
Alias for: string (str) as integer
Alias for: string (str) as integer
Alias for: string (str) as integer
Integer conversion for decimal, octal or hexadecimal strings (C notation) and supplying a default value if the string fails to convert; see 'as c integer (str)'. Void returns the default (which may be void)
Alias for: string (str) as integer else (default)
Alias for: string (str) as integer else (default)
Alias for: string (str) as integer else (default)
Alias for: string (str) as integer else (default)
Floating point conversion for decimal strings and supplying a default value if the string is not a float void returns the default (which may be void)
Floating point conversion for decimal strings and supplying a default value if the string is not a float void returns the default (which may be void)
Convert 'str' to an integer number for decimal digits only, by calling 'integer from str base 10' and ignoring faults; faulty or empty strings return void.
Flip in string (str) all upper to lower case characters and vice versa. Call 'set locale' to include non-ASCII characters
Group decimal digits in (str) by (gm). The input string is scanned from the end, and if the fourth decimal digit is encountered in a row, the group marker (gm) is inserted in between. This ensures that application to an already grouped string does not change it. Also, any string containing digit sequences can be input. If (gm) is void, nothing is done (not $SYSTEM.groupsep used).
Alias for 'string () group ()'
Short for 'string str group $SYSTEM.groupsep'
Replace in string (str) the character at the position (pos) by (repl). The new string may be longer or the empty string.
Alias for: 'string (str) replace character at (pos) by (repl)'
Replace part of a string (str) by a string (repl) The replaced part begins at (pos) and has the size of (repl), i.e. the string length is unchanged.
Alias for: string (str) replace at (pos) by (repl) Deprecated.
Replace part of a string (str) by a string (repl) starting at (from) ending at (upto), both inclusive.
Alias for: string (str) replace from (from) upto (upto) by (repl) Deprecated.
Replace in string (str) all occurences of string (cue) by the string (repl). The scan continues after the replacement. If there is no replacement, the original string is returned; to determine this case, use equality comparison.
Alias for: string (target) replace each (cue) by (repl)
Replace in string (str) several parts in one run, using either a tuple (or row) of (cue, repl) pairs or a map where the keys are the cue strings. The first match provided is used (no longest match). The scan continues after a replacement. Example: res =: string "the quick fox jumped" replace many ((the, der), (fox, fuchs))
Replace in string (str) the first occurence of string (cue) by (repl) If there is no replacement, (str) is returned; to determine this case, use equality comparison.
If string (str) starts with (head), return the tail. If there is no replacement, (str) is returned; to determine this case, use equality comparison.
Replace all numeric HTML entities by the corresponding Unicode character i.e. 'nn;' by the code point nn
Create a map from key-value pairs in a string, e.g. map =: to map by pairs 'a=9 b:"x" c=3.0' The key-value connector character set is many of '=:', the pairs separated by whitespace. Intended to create maps from literals. Preliminary version, (quoted) values may not yet contain whitespace or quotes, and no comma or semicolon as separator.
Alias for: string (str) as map by pairs
Apply runtime options in the row (parm) Returned is a copy of (parm) with the options removed, or (parm) itself if none of the options were present. Runtime options are: --debug --sysinfo Required by runtime system and marked deprecated to discourage normal use.
Parse options in argument row 'args' The argument row is scanned for option entries starting with a minus sign until a double minus single entry is found. Options found are added to the result map, either with the corresponding value, or with '?+' as true. All processed fields are voided in the supplied row; thus, scanning the row delivers the remaining arguments. If a row without voids is desired, use 'shrink row (row)'. Options may be newer long options, starting with a double minus, the tag optionally followed by an equals sign and a value. If old style single letter options with values are used, a string of characters must be provided in 'valopts' to identify these. Using new style options is recommended instead. The caller must handle new and old option aliases.
Alias for: row (args) parse options values (valopts)
Alias for: row (args) parse options values (valopts)
Get single environment variable (key).
Alias for: system get environment
Parse a Query String as produced by HTML Forms After splitting by '&', each element is checked for the format 'key=value' and the pair stored in an map. As positional parameters are rather seldom, these are collected in an row under .posparms Conversion of special characters in the %xx format is done after splitting in fields, keys and values, just after replacing '+' by ' '
Alias for: string (str) parse query
Generate the keys of the map 'map' in ascending order (as opposed to 'give () keys', which lists in undefined order) The keys should be ASCII strings or numbers.
Generate the keys of the map (ary) in descending order (as opposed to 'give () keys', which lists in undefined order) The keys should be ASCII strings or numbers.
Generate the keys of the map 'ary' (as opposed to 'give () keys', which lists in undefined order) using (func) to determine sort order.
Supply the keys of map (this) in ascending order with respect to the values stored.
Supply the keys of map (this) in descending order with respect to the values stored.
Register a function (funcref) to be called at normal exit in reverse order of registering, providing a given parameter. Once registered, it cannot be removed; but the parameter can be replaced by using the same reference (funcref), a void parameter is normal and does not remove the registration. If more than one parameter is needed, use a tuple; if none, just specify and ignore. The returned item reference of the called function is ignored, unless it is a fault item, which is a fatal error. There is no mechanism to stop termination. Doing anything else than cleanup is considered sinful.
Call the enqueued exit functions, and remove them after the call. Done by the runtime system at termination; any other use is discouraged.
Integer exponentiation via square and multiply. Base may be integer or rational, exponent non-negative integer. Same result as base^exponent
Check if argument is a square number using library square root speed up by checking (hex) end digit (only 0, 1, 4 or 9)
Greatest Common Divisor of integer numbers argument is a tuple of positive integers, e.g. a pair if not a tuple, the argument is returned as-is
Integer root for integer exponent: root to the power of exponent is less or equal argument uses bisection method, i.e. accumulates powers of two unless e=2, then 'math int sqrt' is used.
Next floating point random number in the range [0..1[ by ##random next integer / ##$SYSTEM.randmax
Encrypts upto 8 characters (lower 7 bit) of a key string using salt characters to make decrypting more difficult. If salt is void, the time of day is used obfuscated. The result are 2 salt characters, followed by 11 characters encoding 56 bit
Alias for: string (key) encrypt salt (salt)
read true random number from /dev/urandom
calculate MD5 checksum of a string the result is a 16 byte chunk
calculate MD5 checksum of a string the result is a string of 32 hex characters
Calculate MD5 checksum as a compact encoding that can be used as a word or identifier. The result is a string of 24 capital and small letters, starting with a capital letter. The MD5 sum is split into 16 bit chunks, each converted to 3 characters using base-52 encoding starting with a capital letter, because 2^16 / 52^2 = 24.2
calculate SHA1 checksum of a string the result is a 20 byte chunk
calculate SHA1 checksum of a string the result is a string of 40 hex characters
Calculate SHA1 checksum as a compact encoding that can be used as a word or identifier. The result is a string of 30 capital and small letters, starting with a capital letter. The SHA1 sum is split into 16 bit chunks, each converted to 3 characters using base-52 encoding starting with a capital letter.
Create a new hashmap having (cnt) slots and using the hash function (hashfunc), transforming its only argument to an integer, that is taken modulo (cnt) Use 1 slot per 1000 upto 10000 expected entries Defaults when void: slots: 32 hashfunc: system library function 'string () hash'
Create a new hashmap for strings using the default hash function, select the number of slots (1 per 100..1000 entries)
Create a new hashmap for strings using all defaults see: new hashmap size () hash ()
check if hashmap
Obtain value by (key) from hashmap
Set (val) as value by (key) into hashmap (this)
return the number of entries in the hashmap (this) note that this.count is always zero. (unless (this) is a plain map)
A row of all keys (unsorted) To have the keys sorted, use sort (hashmap this keys as row) fast ascending
A row of key, value pairs (unsorted) To have it sorted by keys, use sort (hashmap this key value pairs as row) fast ascending
A row of value, key, pairs (unsorted) To have it sorted by values, use sort (hashmap this value key pairs as row) fast ascending
Supply the keys unordered. Consider using simply: kr =: hashmap this keys as row ?# k =: row kr give values ... Do not use (very inefficient): ?# k =: row (hashmap this keys as row) give values \ inefficient
Supply the values unordered. Consider using simply: kr =: hashmap this values as row ?# v =: row kr give values ... Do not use (very inefficient): ?# k =: row (hashmap this values as row) give values \ inefficient
Supply key-value pairs in ascending order of the keys. Consider using kr =: sort (hashmap this key value pairs as row) fast ascending ?# kv =: row kr give values in particular for descending and other sorts ...
Supply value-key pairs in ascending order of the values. Consider using: kr =: sort (hashmap this value key pairs as row) fast ascending ?# kv =: row kr give values ... in particular for descending and other sorts
Supply the keys in ascending order of the values, using sync sort. Better use hashmap this give value key pairs ascending
Supply the keys in descending order of the values, using sync sort. Better use hashmap this give value key pairs descending
Return a string with hashmap statistics TODO: return a map to be joined as in map (m) key '=' value pairs by ' '
Create a new matrix with dimensions (dimensions), which is a tuple of at least two elements, all positive integers, and whose product does not exceed the available memory. The tuple is saved at .dimensions and must not be changed. (origin) is either a tuple with the same number of elements as (dimension), and gives the lowest index per dimension. If it is an integer, a corresponding tuple is used, if void, 1 is used. As access to a field outside of .origin and .origin+.dimensions would work without crash, but might expand the matrix unexpectedly, there is no dynamic resizing as for rows; the index range is protected by an assertion. Refrain from changing the fields .dimensions and .origin.
Shortcut for 'new matrix size (dimensions) origin (1, 1, ...)
test if matrix
give the key tuples
Simple print all elements, one per line