##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'Class Functions
Register a SIGINT callback which returns the previous setting (may be void). The function is called with an fault item as argument and may return either void or a fault item. In the latter case, the fault item is injected to stop any loop and replaces the next function return. If unprocessed, it is a fatal runtime error; else it is simply dropped.
print a dump of all used items to stderr
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 Void if not a number Same kind as input if not void
Alias for 'math sign ()'
Is string a raw string
Alias for 'string () is raw'
Is string an ASCII string
Is string a localized 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 Fatal if not a fault
Simple hash for integers using Knuth's method. returns x*1327217881 %% 2^31
Simple hash for rationals. returns the hash of the sum of numerator and denominator
Systsem provided hash for any item Integers are hashed with x*1327217881 %% 2^31 Rationals hash the sum of numerator and denominator Strings are hashed by "string (x) hash" Tuples are hashed by "tuple (x) hash" Floats cannot be hashed, because there is no equality All others hash the memory address of the item. Void returns void (not zero)
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.
Increase the lock count of a row. When the lock count is not zero, the item becomes temporarily immutable.
Increase the lock count of a 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.
Decrease the lock count of a row. 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.
Decrease the lock count of a 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
provide a string with the attribte .Isl10n set If it is used nowhere else, the flag is set; otherwise the string is copied and the flag set.
check if void; same as x = ()
check if invalid
check if proxy
check if boolean; same as x.kind = 'boolean'
check if integer (x.kind = 'integer')
check if rational (x.kind = 'rational')
check if float; same as x.kind = 'float'
check if number, i.e. is integer, is rational or is float
check if string; same as x .= '' or x.kind = 'string'
check if row; same as 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: :> x %% 2 = 1 Returns boolean, not integer (use x %% 2 to obtain an integer)
Test if integer is even: :> x %% 2 = 0 Returns boolean, not integer (use x %% 2 to obtain an integer)
Test the n-th bit of an integer number (0 origin). Multiprecision (big) numbers are allowed. Negative targets are possible and treated as in two's complement, Returns boolean, not integer (use (x // 2^n) %% 2 to obtain an integer)
Bitwise multiplication (AND) on machine integers. Negative targets are tolerated and treated as in two's complement.
Bitwise multiplication (OR) on machine integers. Negative targets are tolerated and treated as in two's complement.
Bitwise addition (XOR) on machine integers. Negative targets are tolerated and treated as in two's complement.
Bit inversion (one's complement) on machine integers. Negative targets are tolerated and treated as two's complement.
Bit shift on machine integers. Negative targets and counts larger machine integer bits (63) are erroneous. n>0 is shift left; result is modulo $SYSTEM.intmax//2 n<0 is shift right; integer truncation division. n=0 (or void) returns the argument unchanged. Do not use shifts as purportedly more efficient than multiplications; they are not, unsafe and only obscuring code. Better use x * 2^n or x // 2^n, if this is it.
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 (indices) 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. The range of keys is fixed on the first call (like a map). To deliver all keys, use: from row.first upto row.last
Scan gives actual values of a row from keys as given by 'row () give keys'. Thus void entries are not supplied.
Sort the values in a row (vector) using the C library routine. Same as 'row () sort fast using ()': but optionally providing the compare function with a third argument (extra), if not void.
Sort the values in a row (vector) using the C library routine. If the compare funtion reference (func) is void, the TAV operator '>' is used for ascending numbers or strings. Otherwise it must be a function reference that returns: ?+ if a is "greater" than b = 0 if a is "equal" to b ?- otherwise Sort may be unstable, i.e. changing the order of equal items; for a stable sort use 'row (@) sort ascending using (func)' The row reference is returned. The indices remain, i.e. .Last and .First are unchanged, just the values are sorted.
Alias for: row (@) sort fast using ()
Sort the values of a row ascending using the C library routine. Shortcut for 'row (@) sort fast using ()'
Sort the values of a row descending using the C library routine.
Alias for: row (@) sort fast ascending
Alias for: row (@) sort fast descending
Sort a row (vector) in place using a compare function. If the compare function (func) is void, the standard TAV operator '>' is used giving 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 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 (@) sort fast using (func). The row reference is returned.
Alias for: row (@) sort using (func)
Sort a row (vector) in place using a compare function. Same as 'row () sort using ()', but provides a third (user) parameter to the compare function.
Sort a row (vector) ascending. Shortcut for: row (@) sort using ()
Alias for: row (@) sort ascending
Sort a row (vector) descending. See 'row (@) sort using (func)' but using '<' instead of '>'
Alias for: row (@) sort descending
Sort a row (vector), and keep a second row (val) synchronous. Avoids the use of pairs to be sorted. Uses insert sort and might be slower than using fast sort with pairs. See "row (@) sort using (func)"
Alias for: row (@) sort sync (val) using (func)
Shortcut for: row (@) sort sync (val) using ()
Alias for: row (@) sort sync (val) ascending
Shortcut for: row (@) sort sync (val) using () but with inverted compare
Alias for: row (@) sort sync (val) descending
new map factory function Create a new map
preliminary: convert to a hashed map
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. Use may increase, but improper use may degrade performance. No longer useful as hashed maps have the same perfomance.
Provide the keys of a map as a row. Order is undefined, usually last used first. Keys are unique.
Alias of: map () keys
Provide the values of a map as a row. Order is usually last used first. Because keys may have the same value, the values provided are in general not unique.
Alias of: map () values
Provide keys and their values as a row of pairs. Key order is undefined, but keys are unique.
Provide values and their keys as a row of pairs. Order is undefined, but keys are unique.
Scan to provide the keys of a map unsorted. The keys are saved at the first call, so it is equivalent to: mr =: map (m) keys ?# key =: row mr give values \ row values are the map keys :> key
Remove all duplicate keys and their values in a map. If the map is already marked with .UniqueKeys, returns immediately. Returns void.
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 (@) 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
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
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 bunch (bunch) give values
Alias for bunch (bunch) give values
Truncate floating point to nearest integer (.int)
Truncate number to nearest integer (.int)
Round floating pointto nearest integer (.round)
Smallest integer greater or equal (.ceil)
Deprecated for 'math ceil ()'
Largest integer less or equal (.floor)
round away from zero (.wide)
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.
Alias for: math float ()
Alias for: math float ()
Tell if number is arbitrary precision returns ?+ or ?- for numbers, and void else
Tell if number is arbitrary precision returns ?+ or ?- for numbers, and void else
checks if two rounded (float) numbers are nearly equal, i.e. their difference relative to the larger is (d). If (d) is void, 5.0*$SYSTEM.epsilon is used. Smaller values might give unexpected results, in particular, d < $SYSTEM.epsilon will always return false. Intentionally not a class function, too specific.
Alias for float (@) is near (y) by ()
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 with field names as keys and their values. 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.
Set the fields of a bunch with the values given in an map. For each key in the map, the corresponding field is set. If either argument is void, void is returned. If the keys are not words, it is a fatal error. Void is returned in any case, not the target bunch reference. Intended in buch copy operations after newly created ones, thus does not change fields not in the map.
call function with one parameter return void if func is void
call function with two parameters return void if func is void
call function 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
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. The return code is taken mod 128 (bits 0..6) by most shells. If the retcode is void, return code is 0. If the retcode is not an integer, or less than zero, 127 is used. Note that program termination by a signal often uses 128+signo, i.e. 130 for terminal interrupt.
Create a fault item Sets .errno from parameter, .checked to integer 0, and .backtrace, .lineno and .prototype from system information. All other fields must be set by the programmer.
Create a fault item Sets .errno and .message from parameter, .checked to integer 0, and .backtrace, .lineno and .prototype from system information. All other fields must be set by the programmer.
Alias for: new fault (errno) message (msg)
Dump information for item to standard error depth limited
Dump information for item to standard error
Dump information for item to standard error, if debug output is enabled
information on item without full tree dump to stderr
information on item without full tree dump if debug output is enabled
Enable runtime report
Enable runtime statistics Use 'system info enable'
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
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 (float): .utime user time for current process (whithout children) .stime system time as above i.e. kernel cpu time on behalf of the current process .cutime sums of .utime values for the current and all terminated children .sutime sums of .stime values as befoe
Get the high-resolution times. The parameter is a string selecting the clock source: real wall clock time, including time adjustmets TAI International Atomic Time (monotonic, no leap seconds) monotonic each call is equal or greater the preceeding not continued while suspended. Use only differences process CPU time for process (incl. threads) thread CPU time for the current thread Result is a triple of integers: - seconds - nanoseconds - resolution (in nanoseconds) Resolution means smallest step, not accuracy
Suspend execution for a given interval (in seconds) at least. Argument may be integer or float; the latter used to sleep in microseconds. if >=1.0, truncate to integer.
Alias for: sleep (seconds) seconds
Run a command by the shell. The command string is executed in a new process as /bin/sh -c "string" If the return code is 0, void is returned. If the command exited with a non-zero code, it is returned, unless it is 127, telling that the shell could not execute the command, returning a fault item. If command execution failed, a fault item is returned. Output goes to the terminal. Using this function when the process is privileged (euid = 0) is a fatal error.
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 or get fault mode for operators and return the previous mode as a string: "stop", "delay", "pass" If (fm) is a string, the first character (any case) determines the new fault mode. Silently ignored if no match, or void, or any other item.
Generates numbers starting at (from) down to (last) At end, the next value, i.e. (last-1), is returned.
Generates numbers starting at (from) up to (last) At end, the next value, i.e. (last+1), is returned
Generates numbers starting at (first) up to (last) incremented by (step) The step value is added and may result in an endless loop if zero; hence it is checked initially (not while actually used). At end, the next value > (last) is returned Parameters must be either accurate (integer, rational) or approximate (float) numbers
Generates numbers starting at (first) down to (last) decremented by (step) The step value is subtracted and may result in an endless loop if zero; hence it is checked initially (not while actually used). At end, the next value < (last) is returned Parameters must be either accurate (integer, rational) or approximate (float) numbers
Generates numbers starting at (first) using (step) Depending on the sign of (step), upto or downto (limit) is used. Zero step terminates immediatly (nearly zero for floats). All kinds of numbers are possible.
Simple number enumeration If (start) = (end), it is delivered once. If (start) > (end), the step is +1 else the step is -1.
Generalised scan to generate numbers If (arg) is a triple of numbers (b, e, s), they are generated starting with b, until e (included) with step (s) are produced. The step may be positive or negative; If (arg) is a pair (b, e), the triple (b, e, 1) is used. If (arg) is single integer, the triple (1, e, 1) is used. If (arg) is a tuple and the first element also a tuple, all tuples of arg are used recursively. Examples: give numbers 5 == 1, 2, 3, 4, 5 give numbers 2, 4 give numbers 2 -> 4 == give numbers 7, 3, -1 == give numbers 1 -> 4, 11-> 14 == give numbers (1, 5, 2), (8, 9) No check is made for e.g. step=0 or other combinations that result in nearly endless situations. If not in a scan context, a tuple is created by :> new tuple using `give numbers ()` with arg
Pad the string (@) at the start by the character (chr) to the length (len). If its length already greater than (len), return unchanged.
Pad the string (@) at the 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 (by catenation), then fill at the start 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 (by catenation), then fill at the start 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 (by catenation), then fill at the 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 (by catenation), then fill at the end by the character (chr) 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)
Pad left (len>0) or right (len<0) string or number
Convert a tuple to a string that could be used as a list to re-create. Each element is catenated to a string, joined by a comma, except pairs. which are joined by '->'. Thus it is converted in the default format used by string catenation, including sub-tuples converted recursively.
Convert a tuple to string, enclosed in parentesis. See 'tuple (@) as string' otherwise.
Provide localization for a string. Called automatically for each string literal in quotes (")
Convert a floating point number (x) to a pair of integers (i, e) such that f = i * 10^e (approximately). The maximum number of digits in (i) (when converted to decimal) is normally 15, as determined by $SYSTEM.floatdigits. Used is a machine independent method, that first determines (e) and then (i) by f * 10.0^(digits - e) (i) is rounded and trailing zeros in i are then eliminated, i.e. the last digit is not 0.
Convert a floating point number to an integer, unlimited. The result has upto 15 significant decimal digits from the argument, filled with zeros for the required magnitude: i, e =: float f as pair :> e * 10^i
Create a new map from a tuple of key-value pairs, e.g. 'a' -> 1, 'b' -> 2, ... Duplicate keys overwrite the value.
Create a row from a tuple
Get any map key by value. If there are multiple keys with the same value, it is undefined which key is found. Consider usign "map (@) keys by value (val)"
Scan to provide the actual values of a map unsorted. Uses 'map () give keys' to deliver keys, provides actual value instead of key.
Scan to provide key-value pairs of a map (unsorted) Uses 'map () give keys' to deliver keys, provides actual key-value pair.
Hash for a tuple: same method as for string characters but with a different factor 9973
Tuple number sign negation. A tuple with each element numerically negated is returned. The numbers may be of different kinds.
Tuple number inverse. A tuple with each element numerically inverted (reciprocal) is returned. The numbers may be of different kinds: Float gives float, interger or rational gives integer or rational.
Tuple addition. If both operands are tuples, they must have equal size, and are added elementwise. The second operand may be a plain number that is added to each element of the tuple. For consistency, the first parameter must be a tuple.
Tuple subtraction. If both operands are tuples, they must have equal size, and are subtacted elementwise. The second operand may be a plain number that is subtracted from each element of the tuple. For consistency, the first parameter must be a tuple.
Tuple multiplication. If both operands are tuples, they must have equal size, and are multiplied elementwise. The second operand may be a plain number that is multiplied with each element of the tuple. For consistency, the first parameter must be a tuple. There is no division function; multiply the inverse.
Apply a unary function to all elements of a tuple. Not difficult to do explicitly, but may make the code clearer
Print fault item on standard error (compact information) silent if not a fault does not mark it checked; must be done by caller
Print fault item on standard error (compact information) with function backtrace silent if not a fault does not mark it checked; must be done by caller
If the argument is a fault item, print with backtrace, then exit prematurely with return code '256-@.errno'
If the argument is a fault item, print a message then exit prematurely with return code '256-@.errno'
If the argument is a fault item, print with backtrace, then exit prematurely with return code '256-@.errno'
The real (wall) clock time in seconds as float monotonic from an undefinded start point, for use as differences between calls. See "system clock microseconds" for integer result. Uses "system clock 'monotonic'" as source.
The accumulated cpu time in seconds as float, for all threads in the current process. Usesas source.
The accumulated cpu time in microseconds as integer, for all threads in the current process. While the source may resolve nanoseconds, the accuracy is not better than mircoseconds. Usesas source.
Create a row with a scan function with one argument: r =: new row using `give numbers ()` with 1,5 (func) is a function reference to a scan function with one argument (arg) is the argument to be used for the scan
Create a row with a scan function with two arguments: r =: new row using `from () upto` with 1 5 (func) is a function reference to a scan function with one argument (arg1) is the 1st argument to be used for the scan (arg2) is the 2nd argument to be used for the scan
Create a tuple with a scan functin with one argument, e.g.: r =: new row using `give numbers ()` with 1,5 (func) is a function reference to a scan function with one argument (arg) is the argument to be used for the scan
Create a tuple with a scan function with two arguments, e.g.: r =: new tuple using `from () upto` with 1 5 (func) is a function reference to a scan function with two arguments (arg1) is the 1st argument to be used for the scan (arg2) is the 2nd argument to be used for the scan
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 part of a string. (start) denotes the first character to copy, (len) the number of characters to copy, i.e. the maximum result length, (step) a step value. The start position 1 is the first character; if beyond the last character, the empty string is returned. if negative, it is counted from the end, -1 is the last character. If before the start of the string (<1), it is set to 1. Zero as start postion returns void. The length indicates how many characters to copy at most. Zero or negative return an empty string. The step may be any integer and is added to the current position once a character is copied. Zero results in the start character duplicated as many times as (len) gives. Negative values go back in the string. RAW or ASCII strings are processed bytewise and result in the same (no check if RAW is ASCII then, do it yourself) Character means UTF code point.
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 (@) from (first) length (len)
Alias for 'string (@) 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 (@) from (first) upto (last)
Alias for 'string (@) from (first) upto (last)
Copy the part of the string 'src' that starts at 'first' upto the end. Equivalent to 'string (@) clip from (first) upto (src.count)'
Alias for 'string (@) from (first)'
Alias for 'string (@) from (first)'
Copy the part of the string 'src' upto the 'last' character. Equivalent to 'string (@) clip from (1) upto (last)'
Alias for 'string (@) upto (last)
Alias for 'string (@) 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 determined by 'base' using the C library function 'strtol' or the GNU multi precison library equivalent 'mpz_.set_str'. 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 (@) 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 (@) as integer base (basespec)'.
Alias for: string (@) as integer clib (base)
Alias for: string (@) as integer clib (0) i.e. using C conventions
Alias for: string (@) 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 (@) 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 1.0E308 produces 15 leading significant digits, followed by many insignifant ones.) Neither rationals nor arbitrary precision (big) numbers can be used. A void argument returns void. To be used provisionally in tuflib for 'format () ()'; improper use may crash programmes until more checks are programmed
Alias for: system cformat (format) number (num)
Alias for: system cformat (format) (num)
Convert a float to a string in exponential format with {d} digits precision. There is one (non-zero) digit, followed by the decimal point, followed by (d) significant digits. (d) is between 1 and 14 (adjusted if out of range)
Convert a float to a string in strict fixed point format with (d) digits after the decimal point. {d} is between 1 and 14 (adjusted if out of range, void is 14). If (@) < 1.0, one insignificant zero is followed by the decimal point, a block of insignificant zeros, followed by the significant digit(s) (also trailing zeros). If (@) < 0.001 or > 10.0^(d-1), insignificant or excessively many digits would be produced; instead, a fault item (exponential form in .info) is returned.
Convert a float to a string in fixed point format with (d) digits after the decimal point. {d} is between 1 and 14 (adjusted if out of range). If (@) < 1.0, one insignificant zero is followed by the decimal point and insignificant zeros, followed by the significant digit(s) (which may be a zero). If (@) < 0.001 or > 10.0^(d-1), insignificant or excessively many digits would be produced; instead, exponential form (with full precision) is returned.
Convert a float to general format with (d) digits. {d} is at least 2 and at most 15 (adjusted if out of range) If (@) < 0.001 or > 10.0^(d-1), exponential format is used. If (@) < 1.0, an insignificant zero is followed by a decimal point and upto 2 insignificant zeroes, followed by the significant digits, including zeroes. If (d) is void, the standard conversion (float () as string) is used that does not have trailing zeroes after the decimal point.
Returns a (decimal) string converted from a float. Floating point numbers are shown with upto 6 decimal places in fixed point (decimal) form with always a decimal point and neither trailing zeros nor insignificant digits, except zeros around the decimal point if < 1.0. If < 0.001 or > 99999.9, exponential format is used. This is the same format used for catenating strings with numbers.
Returns a (decimal) string converted from an integer. This is the same format used for combining strings with numbers.
Returns a (decimal) string converted from a rational. Uses two decimal integers for denominator and numerator, connectd by a slash. 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. If the argument is already a string, it is returned unchanged. 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.
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 (@) 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
Alias for 'string (@) case starts upper'
Tests the first character in string (@) 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
Alias for 'string (@) case starts lower'
Convert string characters to upper case Void is returned void, empty string unchanged Call 'set locale' to convert non-ASCII characters
Alias for string (@) case to upper
Convert string characters to lower case Void is returned void, empty string unchanged Call 'set locale' to convert non-ASCII characters
Alias for string (@) case to lower
Simple Hash function for strings (with collisions) returns an unsigned integer number calculated iteratively by sum =: (sum * 127 + byte[i]) where byte[i] is the i-th byte (not code point) and the sum starts with the number of bytes. The sums are taken modulo 31 or 63 bits. The function is ten times quicker than MD5 or SHA1, and has no collisions with 25000 words from unixdict.txt. Although the runtime is proportional to the number of bytes, it is still quicker than creating and processing these strings so any variant that uses only head and tail need not be considered.
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 See print ()
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 the argument is a tuple, the elements are printed individually, separted by a single blank space. Strings are printed literally, without quotes. Integers are printed as (full) decimal numbers. Rationals are printed as two decimal numbers with a slash. Real numbers are printed in a default format (as if catenated to a string). Rows and maps are printed as [n] and {n}, where n is the number of elements. A fault item is represented by '' (without quotes) This is specific to print and not supported by string catenation. Because a tuple print is recursively, it is effectively flattened (all values shown as one long list separted by blanks). If output shall be different, use 'tuple (@) as string' or catenate it to the empty string: x =: 1, 2, 3, 'a', 3.5 print '' _ x For a different separator, use 'join (tuple) by (sep)'. 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. Same as: error print '@&lineno;:', _ mixed'
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
Print source position and argument to standard error if the global DEBUG flag is set.
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.
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.
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.
check if a file stream
Created a command pipe (command) and a stream to read the command output. If the environment variable 'TAVPL_NO_SHELL' is set, this is a fatal error. Note that /bin/sh is used, which is often /bin/dash
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 'TAVPL_NO_SHELL' is set, this is a fatal error. Note that /bin/sh is used, which is often /bin/dash
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 no error occured and the return code of the command was zero, void is returned. If the return code of the called command is between 1 and 255, it is given back as an integer. The value 255 is dubious. If the pipe closed normally, but the shell used returns an error, a fault item is returned; If the pipe closed abnormally, a different fault item is returned. Note: Signal 13 (SIGPIPE) occurs if data is left in the pipeq If the pipe close signals a system error coder (-1, errno), a corresponding fault item is returned. In all these cases, the original return code is the .errno
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.
check if a command stream
Returns the attributs of a filename or open file stream as a map with zero elements with user fields: The field '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, devid Boolean fields: symlink, directory If the file does not exist, a fault item is returned. The 'space' field 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 field to be true. Information about the symlink itself cannot be obtained by this function. The symlink field 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.
Alias for: file (filename) attributes
Alias for: file (filename) attributes
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.
Ask the user on the controlling terminal with the string (prompt) and return the characters typed in as reply as a string. If the last character is a newline, it is not used. If it fails for any reason, e.g. no controlling terminal, void is returned. The maximum reply string is 255 bytes. Can be used in a signal callback.
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 'math int () is square' how to test for a perfect square
Split a float into a normalized mantissa as float and base 2 exponent as (signed) integer Let m, e =: float (x) split binary then ! is m float & is e integer ! x %= m * 2^e \ as near as possible ! 0.5 <= m & m < 1.0 There are no conversion errors; just the binary machine representation is extracted.
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 result (or other expression) into a scan. Repeats until the value (val) is void (or a fault item). Result of this function is (val).
Wrap a function result (or other expression) into a scan. Repeats while the value (val) is greater than zero (or a fault item). Result of this function is (val).
Wrap a function result (or other expression) into a scan. Repeats while (cond) is true (or (val) ia a fault item). Result of this function is (val).
Return the largest value of a tuple, row or map The values must be comparable by '>' If there are no values, void is returned If not a row, tuple or map, returns the argument
Alias for: maximum of (trm)
Alias for: maximum of (trm)
Alias for: maximum of (trm)
Alias for: maximum of (@)
Alias for: maximum of (@)
Return the smallest value of a tuple, row or map The values must be comparable by '<' If there are no values, void is returned If not a row, tuple or map, return the argument
Alias for: minimum of (trm)
Alias for: minimum of (trm)
Alias for: minimum of (trm)
Alias for: minimum of (@)
Alias for: minimum of (@)
Generate permutations of integer numbers (start) and (last) must be tuples with 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)
check for values in a bunch if (src) is a tuple, try for every element. Otherwise, shortcut for src::find val ~= ()
Create a tagged row. Shortcut for: rv =: new row rv.tag := tagname Note that the shortcut row factory [a, b, ...] is 'tuple a, b, ... as row'
Create a tagged row wit an initial size. Shortcut for: rv =: new row size int rv.tag := tagname
Copy a row's values and keep the keys (no renumbering). For the latter, used 'row () shrink' (modifies, does not copy). Fields and the tag are void (not copied).
Copy a row's values and keep the keys (no renumbering). For the latter, used 'row () shrink' (modifies, does not copy). Fields are preserved (but not a tag, as it cannot be changed).
Compact row cells in-place so that void entries are removed by renumbering the keys, starting at .First. If there are no void cells, nothing is changed. No space is released (as common with rows), but .Last set to the index of the last non-void cell or to .First-1 if all are void. setting @[] etc then re-uses the already allocated memory. Returns the input row for convenience and compatiblity
Remove void entries old version works on a copy
Copy a part of a row from (from) to (to) All void elements are discarded 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. Neither fields nor a tag are copied. Works for tuples alike.
Append many values at the end of an existing row: ?# val =: bunch rmt give values @[] =: val New keys are created for the appended values from .Last+1 on. Append a single value by 'r[] =: val'. 'row r append r' is possible and duplicates the entried. 'row r append r, ' creates a cylic link (memory leak)
Stow new values at void cells until filled, then append. The values are taken from a row, map or tuple (rmt). Does not change the keys for the non-void cells. For large rows with a few void cells, just appending and skipping keys with void values may be more efficient. For a single value, use a tuple with one element. 'row r stow r' is possible and duplicates the values.
Voids duplicate values in a row with adjacent duplicates (sorted). Returns immediately if there are none (.Count = .Last - .First + 1) The row is scanned from first to last, and for each sequence of equal values, all but the first one are set void. Thus the keys are not renumbered. Often used in the sequence row this sort ascending row this dedup bursts row this compact Use the slower 'row () dedup' if unsorted
Alias for 'row () dedup bursts'
Voids duplicate values in any (unsorted) row in-place. Returns immediately if there are none (.Count = .Last - .First + 1) The row is scanned from first to last, and each value is searched in the remaining part, deleted if found (by guarded equality '?=') Often used in the sequence rok =: map @ keys row rok dedup Use 'row () dedup bursts' if sorted.
Voids duplicate values in a row, using a callback for comparison. The row is scanned from first to last, and each value is searched in the remaining part, and deleted if found equal, as determined by (func) with two parameters returning a boolean value, when true (?+), the cell with the second value is voided. Often used in the sequence rov =: row r values row rov dedup using `tuple (a) equals (b) first`
Voids duplicate values in a row, using a callback for comparison. The row is scanned from first to last, and each value is searched in the remaining part, and deleted if found equal, as determined by (func) with three parameters returning a boolean value, when true (?+), the cell with the second value is voided. The first two are the items to compare, and the third is passed from the call as extra parameter. Often used to have unique keys in: rok =: map @ pairs row rok dedup using `tuple (a) equal (b) cell (n)` with 1
Provide the keys with not void values as a row
Provide the not void values of a row as a row
Search a row for the (first) key of a value (val) Return the key (index) if found, or void if not found. Guarded equality (?=) is used, thus the row may have mixed items. The keys are probed in ascending order until the first found.
Search a row for all keys of a value (val) Return a row of keys; with .count = 0 if none found. Guarded equality (?=) is used, thus the row may have mixed items. All keys are probed in ascending order.
Search a tuple for a value (val) Return the key (index) if found, or void if not found. Uses simple search in ascending order of natural numbers and guarded comparison.
Sort a row with pairs of values for ascending pair's first elements. Shortcut for row @ sort using `tuple (p) greater (q) cell (n)` with n
Sort a row with pairs of values for ascending pair's first elements. Shortcut for row @ sort using `tuple (p) greater (q) cell (n)` with n
Compare (n)-th cell of tuples Returns ?+, (), ?- if greater, equal or less Used as a callback in sort. Not a class function, use direct expression, e.g. p[n] = q[n]
Compare (n)-th cell of tuples Returns ?+, (), ?- if less, equal, greater Used as a callback in sort. Not a class function, use direct expression, e.g. p[n] = q[n]
Compare (n)-th cell of tuples Uses guarded compare (?=) for any kind of item. returns boolean ?+ , ?- Used as a callback in dedup. Not a class function, use direct expression, e.g. p[n] ?= q[n]
Create a new tuple with one more element, (val). To add more than one, use 'row () append ()' and convert to a tuple. Consider using a row in the first place instead of the immutable tuple.
Slice a tuple. Alias for row (row @ from from upto upto) as tuple
Create a new map from a (sparse) row (or tuple) 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 (@) 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 value-key-pairs (unsorted) Implemented as: pairs =: new row size @.count ?# key =: map @ give keys pairs[] =:@{key}, key :> pairs Sorting by value is simple due to the comparison rules for tuples: row (map @ value key pairs as row) sort fast ascending
Alias for: tuple (tup) as map
Alias for: tuple (tup) as map
Alias for: tuple (tup) as map
Add to a map pairs of key and value, from a row, map or tuple. Just a shortcut for: ?# lv =: bunch rmt give values @{lv.1} =: lv.2
Copy a map without fields.
Copy a map including fields efficiently. Uses 'map () copy lean'. Fields are preserved (but not a tag, as it cannot be changed).
Returns a string of key-value-pairs for a map The keys and 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. String values are enclosed by calling 'string (str) wrap (qr)', but here with the default '"' for (qr).
Search a map for a key with value (val) Return the key if found, or void if not found. Guarded equality (?=) is used, thus the row may have mixed items. The keys are probed as given by 'map @ give keys'.
Search a map for all keys with value (val) Return a row of keys; with .count = 0 if none found. Guarded equality (?=) is used, thus the row may have mixed items. All keys are probed as given by 'map @ give keys'.
Invert a map: The values are the new keys, the keys are the values. If a value has more than one key, a tuple is used to hold all keys. If the result's count is smaller than the input's, there are tuples.
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'
Gives the lines obtained from an URL. End-of-file is returned as void. For URL types and error codes, see 'man curl' Uses a shell pipe and the 'curl' program, thus only if shell access is allowed.
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
Return the newest file in (directory) that matches a filename (pattern) as by: string (string) matches filename (pattern) Void (directory) is the current directory '.' Time stamp used is last modification time. Fault items are passed unchanged.
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 variable 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 single character (c) is in a string Wrapper for: string (str) locate (c), returning boolean Intended for optimisation if c is a single character
Alias for: string (str) has character (c)
Alias for: string (@) has character (c)
Count in a string from (start) the characters found in (accept). Zero is returned if the character at start is not in (accept), or if start is beyond the end. Negativ (start) counts from the end (-1 is last); if before the begin, 1 is used. Zero (start) is an assertion violation.
Count in a string from (start) the characters not found in (reject). Zero is returned if the character at start is in (reject), or if (
Clip from a string the longest part with characters in (accept), starting at (start). 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 () from (start) many of (accept)'
Clip from a string the longest part with characters not in (reject), starting at (start). 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 () from (start) none of (reject)
Give clips of a string separated by any single character in (sep). If two separators follow directly, an empty string is returned, also for leading and trailing separators. If the target is the empty string, nothing is given.
Give clips of a string separated by any combination of characters in (seps). An empty string is returned only if there is a leading or trailing separator character. If it is the empty string, nothing is given. See also 'string (@) give clips by any of (seps)'
Give clips of string 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 a string into an row of strings using any of the single characters from (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 a string into an row of stings using any combination of the characters in (seps) as separators. If separators are leading or trailing, or are leading or trailing, an empty string is provided (not a void). The empty string returns a row without elements Uses 'string @ give clips by many of seps' to fill the row.
Split a string into an row of strings using (seps), which is either a tuple or row of strings, or a single string. using any one of the string(s) given by (seps) as separator, which is either a single string or a tuple or row. 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.
Tell if a string has string (what) at position (pos) 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: string () from 1 has head
Alias for: string (str) has head (head)
Alias for: string (str) has head (head)
Alias for: string (str) has head (head)
Check if a string 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)
In string (@), replace all tab characters by blanks to advance the next tab position, i.e. pos %% ts = 1
convert a string to a row of (single character) strings
Join cell values of a 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) in a row to a string with separator (sep). The keys are in ascending order.
Catenate all values of a s, 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 'bunch () give values' resolves it.
Join all keys of a map to a string, separated by (sep), in undefined order
Join all values of a map to a string, separated by (sep). Standard scan is used, thus the order is undefined.
Remove from the beginning of a string all characters that are in (chars), and return the resulting string.
Alias for: string (@) without leading (chars)
Remove all leading whitespace from a string. Shortcut for string @ without leading #Whitespace
Alias for: string (@) without leading whitespace
Remove from the end of a string 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. Shortcut for string str without trailing #Whitespace so beware of redefining the named constant from the standard library
Alias for: string (str) without trailing whitespace
Put a string in Quotes. Quotes inside are escaped as '"', and '"' is replaced by '"' before. Numbers instead of a string are converted to strings.
Alias for: string (string) quoted
Enclose a string by (wrap) If (wrap) is a string, any occurence of (wrap) inside is doubled, then the result enclosed in (wrap) If (wrap) is a tuple, returns 'wrap.1 _ arg _ wrap.2', if (wrap) is a reference to a function (with one parameter), the return value is returned, thus should be a string. The function must handle all kinds of arguments. See `string () quoted` for escaping '&' for HTML.
Convert integer (@) 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 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. Upper and lower case are distinguished, thus hex digits may not contain lower case letters (but see 'string (str) as integer literal')
Integer conversion for strings with decimal digits. Alias for 'string str as integer base ()'
Alias for: string (str) as integer use 'as clib integer (str)' if 0x and leading zeros should be possible
String to integer conversion ignoring characters given in (ign), e.g. spaces, underscores, apostrophes Just first removes each character in (ign) before the conversion. (ign) can be void or the empty string.
String to integer conversion ignoring characters in (ign) before conversion. If it still is not valid, use the alternate (else). (ign) can be void or the empty string.
Integer conversion for literals in TAV (or Python3) format: Either (decimal) digits (including leading zeroes), or 0xABC for hex, 0o765 for octal, or 0b01001 for binary. Returns either an integer or a fault item provided by string () as integer base () Apostrophes and underscores are removed prior to conversion.
Integer conversion for decimal, octal or hexadecimal strings in integer literal notation (same as in Python 3) , i.e. decimal digits or 0x1Ab or 0o127 or 0b010101, and supplying a default value if the string fails to convert; see 'string () as integer literal. Void returns the default (which may be void)
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)
Convert a string 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 a string all upper to lower case characters and vice versa. Call 'set locale' to include non-ASCII characters
check if whole string is upper case umbrella for '@ = string @ case to upper'
check if whole string is lower case umbrella for '@ = string @ case to lower'
Group decimal digits in a string. If there is a decimal point, grouping starts there in both directions, otherwise at the end. The parameter (gm) may be a pair of the group character and the number of digits to group; if not a pair, 3 is assumed. From the start point, the group character is inserted before resp. after each fourth decimal digit in a row, so application to an already grouped string does not change it. If (gm) is void, "'" is used. If the input is a tuple (neither row nor map), a tuple is returned with each element grouped If the input is not a string, it is converted by string catenation. Beware that floting point numbers have only a few digits per default.
Alias for 'string (str) group ()'
Alias for 'string (str) group (gm)'
Alias for 'string str group ()'
Replace in a string the character at the position (pos) by (repl). The new string may be longer or the empty string.
Replace part of a string by a string (repl) The replaced part begins at (pos) and has the size of (repl), i.e. the string length is unchanged.
Replace part of a string by a string (repl) starting at (from) ending at (upto), both inclusive.
Replace in a string all occurences of string (cue) by the string (repl). If (cue) is a tuple, the function is called for each element. (see alternatively 'string (@) replace many (pairs)'). The scan continues after the replacement. If there is no replacement, the original string is returned; to determine this case, use equality comparison. If (cue) is void or the empty string, nothing is done and the original string returned. If
Replace in a string each of the characters in (cue) by (repl). If (cue) is a string with more than one character, the string replacement is called for each character, one after the other, thus different to the replacement if (cue) is a tuple. Otherwise call string replacement with cue directly. Beware of characters in (cue) also in (repl).
Alias for: string (target) replace each (cue) by (repl)
Replace in a string several parts in one run, using a tuple (or row or map) of (cue, repl) pairs. The pairs in the tuple or row are probed in ascending order for a match; for the first one found, the cue is replaced, and the scan continued after the replacement from the beginning again. The cue may be the empty string; then the replacement is inserted after each character. If a cue is a prefix for another cue, it must be placed second; there is no longest match etc. For a map, the keys are searched and replaced by the values. The keys are used as provided by the key scan, in hard to predict order (mostly last used first). Thus, none of the keys should be the prefix of another one. Example: s =: "the quick fox jumped" print string s replace many 'the'->'der', 'fox'->'fuchs' This simple approach has the advantage of easy predictability in performance and result.
Replace in a string the first occurence of (cue) by (repl) If there is no replacement, (str) is returned; to determine this case, use equality comparison.
If the string starts with (head), return the tail, else the string unchanged.
Replace all numeric HTML entities by the corresponding Unicode character i.e. 'nn;' by the code point nn
Give each character in a string individually.
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
Parse options in an argument row The argument row is scanned for option entries starting with a minus sign until a double minus single entry is found. Options found are collected in a result map, either with the corresponding value, or with '?+' as true. All processed cells are voided in the supplied row; thus, scanning the row delivers the remaining arguments. If a row without voids is desired, apply 'row () compact'. 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.
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' ordered, same as 'map (@) give keys using (func)', but here the func has a third parameter, the user data (extra), which allows `tuple () greater () with ()' for cell selection.
Generate the keys of the map 'ary' ordered (as opposed to 'give () keys', which lists unsorted) The function (func) must have two parameters to compare and deliver ?+, () or ?-, where ?+ is for "greater", void for equal, and ?- else.
Supply the keys of a map in ascending order with respect to the values stored.
Supply the keys of map (@) in descending order with respect to the values stored.
Get map key(s) by value. If there is none, void is returned. If there is only one, the key is returned. Otherwise, it is a tuple of keys.
Format a (list of) expression(s) according to a format string (fmt). The format string is copied until a percent sign ('%') is found that starts a formatted insertion of a values. If another percent sign follows directly, it is copied and the other one ignored. Otherwise, the insertion specification ends at a (mandatory) semicolon. If initally a decimal number n is followd by a colon, the n-th element from the list of expressions is converted (may be void, shown as '()'). Otherwise, the ordinal number of the field is used. Any number of non-digits may follow; they are set aside as flags. A decimal number indicates the minimum field width. If the conversion result is smaller, it is padded with blanks or the character indicated by a flag. If absent, no padding is used. A point ('.') followed by a decimal number gives the precision for floats and maximum field width otherwise. The field is terminated by a semicolon. If none is found, or a percent sign encountered before, the format string is returned unchanged which serves as error indicator. Flags are: - pad to the right, i.e. the result is left adjusted + use a plus sign for positive numbers (and zero) 0 pad with zeroes to the left, no padding to the right p pad with points in both directions · pad with Unicode '·' (·) in both directions " Encloses in (double) quotes after truncation ' group the result by "'" (see 'group' function) _ group the result by "_" (see 'group' function) ⏨ use Unicode '⏨' instead of 'e' in exponential format … use '…' to mark truncation (replace last char) d use decimal digits for integer numbers x,X use hexadecimal digits for integer numbers o use octal digits for integer numbers b use binar digits for integer numbers f,F use fixed point format for floating-point numbers e,E use exponential format for floating-point numbers g,G use fixed format for small and expoential for large floats The result of conflicting flags is undefined. Flags not applicable are silently ignored. See also the function format convert (src) width (width) prec (prec) mods (mods)
Get single environment variable (key).
Alias for: system get environment
Register a function reference (funcref) to be called at normal exit in reverse order of registering, providing a parameter. If more than one parameter is needed, use a tuple; if none is required, use one and supply void. Functions are unique; if the same function is specified again, just the parameter is changed, which can be void. To delete a function, use 'system on exit remove (funcref)' The returned item reference of the called function is ignored, unless it is a fault item, which is a fatal error. Doing anything else than cleanup is considered sinful, in particular calling 'system exit ()' supressing more exit functions. The item supplied as parameter keeps refernced
Delete a registered system function
Integer exponentiation via square and multiply. Base may be integer or rational, exponent non-negative integer. Same result as base^exponent
Tell 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: result {r} to the power of {e} is less or equal {n} r^e ≤ n if {e}=2, then 'math int sqrt' is used. uses bisection method, i.e. accumulates powers of two
Next floating point random number in the range [0..1[ by random next integer / $SYSTEM.randmax after float conversion
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 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
Obtain a line from the terminal with optional prompt message using the readline() library Note that no input is the empty string, and CTRL-D returns void. CRTL-C while in readline returns a fault.
DOM parser for well-fromed XML documents from a file. Each node is a -- possible empty -- row of lower level nodes. The node tag is in .tag, the attribute map in .attrs, Character data for a node is catenated as-is in .cdata; use a library routine to compress white space. Outside the top node, character data is ignored. The parent of a node is set in .parent as a proxy reference The tag in the corresponding end element is stored in .endtag. Comments and processing instructions are ignored. The DOM parser uses the SAX parser, see there.
SAX parser for XML Create a sax parser object by ctx := {} \ or any other user data sp =: new sax parser ctx Then set callback functions (see below): sp.elementBegin =: `...` ... and supply document lines by sax (sp) supply (str) The string (str) is used as scan buffer and parsed: All leading characters that are not a '<' are provided as .characterData and an empty string is returned. Unless the buffer is empty, it now starts with a '<', and a following '>' is searched; if there is none, parsing is stopped and the buffer string returned to be extended. The characters between the '<' and '>' are parsed as an element and the corresponding callback (begin and end) is called, and the string including '<' and '>' discarded; if it is not an element, the string is provided via .otherElement (including '<' and '>' and then discarded. Unless the buffer is empty, the scan is repeated. Thus, a typical use (without fault handling) is: rbt =: '' \ residual buffer tail ?# lne =: give lined from file ... rbt =: sax sp supply rbt _ lne _ '&nl;' The callback functions () all have the context (user data) as first parameter: .elementBegin - context (user data) - tag string - attribute map .elementEnd - context (user data) - tag string .characterData - context (user data) - next (piece of) character data .otherElement - context (user data) - everything between '<' and '>' that is not an element. Entities are not resolved, but remain as-is in the strings; use own or library functions to convert. Namespaces are possible, as any character not whitespace or '>' is accepted as element or attribute name. To stop scanning, set a flag in the context and stop the supply loop. No check for well-formnedness is done; in particular, an end tag is not checked against the tag name of the hierarchically corresponding begin tag; this could be done be the caller in the .elementEnd callback. Can be used to parse HTML if the caller checks the nesting etc.
Supply input data and process input.
create a complex number pair
create a complex number pair
Add two complex numbers
Subtract two complex numbers
Multiply complex numbers
Divide complex numbers
Absolute value (vector length) of a complex number (single real) i.e. sqrt x.1^2 + x.2^2
Real part of a complex number
imaginary part of a complex number
CIS function for a real number, Returns cos x.re, sin x.im
Argument of a complex number (angle in radians)
print a complex number
Add two numbers in decimal float format. The lower exponent is used, the result is exact, not rounded. If a precision is given by the operands, the minimum is propagated.
Subtract two numbers in decimal float format. The lower exponent is used, the result is exact, not rounded. If a precision is given by the operands, the minimum is propagated.
Change sign of a number in decimal float format.
Multiply two numbers in decimal float format. If no precision is given, the result is not rounded and thus exact. Otherwise, the smaller of the (not void) precision is used.
Divide two numbers in decimal float format. If no precision is given, the default (200) is used. Otherwise, the smaller of the (not void) precision is used.
Test if a dfloat is > 0
Test if a dfloat is < 0
Compare for greater
Compare for less
Round and normalise a number in decimal float format. If no precision is given, the default (200) is used.
Normalise a number in decimal float format, i.e. remove trailing decimal zeroes and adjust the exponent.
Change (or set) the precison of a decimal float. Default precis
Convert a decimal float number to standard float. No error checking, precision is ignored.
Convert integer number to decimal float. No rounding necessary, no precision set. Result is normalised.
Convert a decimal float to a string. There is always a decimal point (it's not an integer), and no extra (insignificant) trailing zeroes -- unless there is only one nonzero decimal digit If trailing or leading zeroes would be necessary, an exponent is used. The decimal point is fixed '.' (not localized)
Convert a standard (binary) float to decimal float. Parameter is the assumed precision in decimal digits, default is sensible maximum, i.e. $SYSTEM.floatdigits (normally 15). When larger ones are used, the extra digits are at least noisy, see 'float (f) pair ()'.
Convert rational number to decimal float Just divides numerator by denominator, with the precision (in decimal digits) given or the default (if void)
Create a dfloat pair from an integer, float, rational or string using the default precisions Void if the string was not understood.
Convert a string to a decimal float At most one decimal point is allowed. Characters in (ign) are removed first.
Convert a string to a decimal float At most one decimal point is allowed. Alias for 'string (this) as dfloat ignore ()'
square root if argument has no precision, argument must not be negative