# Cell Functions The intrinsics are constants and functions that are built into the language. The use statement is not needed to access them. A programmer is not obliged to consult the list of intrinsics before naming a new variable or input. New intrinsics may be added to Misty without breaking existing programs. Constants false This is the value of 1 = 0. The false value is one of the two logical values. true This is the value of 1 = 1. The true value is one of the two logical values. null This is the value of 1 / 0. The null value is an empty immutable object. All attempts to obtain a value from null by refinement will produce null. Any attempt to modify null will disrupt. Any attempt to call null as a function will disrupt. null is the value of missing input values, missing fields in records, and invalid numbers. The |default operator can detect the presence of null and substitute another value. pi This is an approximation of the circle expression circumference / diameter, or to be precisely approximate, 3.1415926535897932. Creator Functions The creator functions are used to make new objects. Some of them can take various types. All of these functions can return null if their inputs are not suitable. Array array(number) Make an array. All of the elements are initialized to null. number is a non-negative integer, the intended length of the new array. array(number, initial_value) Make an array. All of the elements are initialized to initial_value. number is a non-negative integer, the intended length of the new array. If initial_value is a function, then the function is called for each element to produce initialization values. If the function has an arity of 1 or more, it is passed the element number. array(array) Copy. Make a mutable copy of the array. array(array, function, reverse, exit) Map. Call the function with each element of the array, collecting the return values in a new array. The function is passed each element and its element number. function (element, element_nr) If reverse is true, then it starts with the last element and works backwards. If exit is not null, then when the function returns the exit value, then the array function returns early. The exit value will not be stored into the new array. If the array was processed normally, then the returned array will be shorter than the input array. If the array was processed in reverse, then the returned array will have the same length as the input array, and the first elements will be null. The elements in the new array that were not set due to an early exit will be set to null. This is like the for function except that the return values are collected into a new array. array(array, another_array) Concat. Produce a new array that concatenates the array and another_array. array(array, from, to) Slice. Make a mutable copy of all or part of an array. array: the array to copy from: the position at which to start copying. Default: 0, the beginning. If negative, add length(array). to: the position at which to stop copying. Default: length(array), the end. If negative, add length(array). If, after adjustment, from and to are not valid integers in the proper range, then it returns null. from must be positive and less than or equal to to. to must be less than or equal to length(array). array(record) Keys. Make an array containing all of the text keys in the record. The keys are not guaranteed to be in any particular order. array(text) Split the text into grapheme clusters. A grapheme cluster is a Unicode codepoint and its contributing combining characters, if any. array(text, separator) Split the text into an array of subtexts. The separator can be a text or pattern. array(text, length) Dice the text into an array of subtexts of a given length. Logical logical(value) if value = 0 \/ value = false \/ value = "false" \/ value = null return false fi if value = 1 \/ value = true \/ value = "true" return true fi return null Number number(logical) The result is 1 or 0. number(number) The number is returned. number(text, radix) Convert a text to a number. The optional radix is an integer from 2 thru 37. (See Base 32.) The default radix is 10. number(text, format) number format format radix separator decimal point "" 10 .period "n" "u" _underbar "d" ,comma "s" space "v" .period ,comma "l" dependent on locale "i" _underbar "b" 2 "o" 8 "h" 16 "t" 32 "j" 0x- base 16 0o- base 8 0b- base 2 otherwise base 10 The number function converts a text into a number. If it is unable to (possibly because of a formatting error), it returns null. The format character determines how the text is interpreted. If the format is not one of those listed, then null is returned. Examples: assign result: number("123,456,789.10", "d") # result is 123456789.1 assign result: number("123.456.789,10", "v") # result is 123456789.1 assign result: number("123.456.789,10", "d") # result is null assign result: number("123 456 789.10", "s") # result is 123456789.1 assign result: number("12.350") # result is 12.35 assign result: number("12.350", "v") # result is 12350 assign result: number("12.350", "i") # result is null assign result: number("666") # result is 666 assign result: number("666", "b") # result is null assign result: number("666", "o") # result is 438 assign result: number("666", "h") # result is 1638 assign result: number("666", "t") # result is 6342 assign result: number("0666") # result is 666 Record record(record) Copy. Make a mutable copy. record(record, another_record) Combine. Make a copy of a record, and then put all the fields of another_record into the copy. record(record, array_of_keys) Select. Make a new record containing only the fields that are named by the array_of_keys. record(array_of_keys) Set. Make a record using the array as the source of the keys. Each field value is true. record(array_of_keys, value) Value Set. Make a record using the array as the source of the keys. Each field value is value. record(array_of_keys, function) Functional Value Set. Make a record using the array as the source of the keys. The function is called for each key, yielding the field values. Text text(array) Convert an array to text. The array can contain text and unicode codepoints. All are concatenated together to make a single text. text(array, separator) Convert an array to text. The array can contain text and unicode codepoints. All are concatenated together to make a single text. The separator text is inserted between each piece. The default separator is the empty text. text(number, radix) Convert a number to text. The optional radix is an integer from 2 thru 37. (See Base 32.) The default radix is 10. text(number, format) The format of the format text is format format_separation format_style format_places format_separation "" digit format_style 'b' 'c' 'e' 'h' 'i' 'l' 'n' 'o' 's' 't' 'u' format_places digit digit digit Convert a number to formatted text. The text function converts a number to a text. It takes a format text input. A format text contains a style letter that controls how a text is produced from the number. It is optionally preceded by a separation digit, and optionally followed by a places digit. There are real styles and integer styles. If the format input is not a proper format text, then null is returned. Separation is a character that is placed between digits to improve readability. If separation is 0, then there is no separation. If separation is 3, then a character is inserted before the quadrillions, trillions, billions, millions, and thousands. Places is the number of places to display after the decimal point (in real styles) or the minimum number of digits to display with zero-fill (in integer styles). If places is 0, then as many digits as necessary are displayed. Places can be zero or one or two digits. real style base default separation default places decimal point separator e exponential 10 0 0 .period n number s space 3 space u underbar _underbar d decimal 2 ,comma c comma ,comma .period l locale determined by the locale The real format options are "e" uses scientific notation. One digit is placed before the decimal point, and all of the remaining digits after, followed by e and the exponent. "n" uses .period as the decimal point and no separator. It is the format used for numbers in Misty source programs and JSON. Scientific notation is used if the number value is extreme. "s" uses .period as the decimal point and a space as the separator. "u" uses .period as the decimal point and _underbar as the separator. "d" uses .period as the decimal point and ,comma as the separator. "c" uses ,comma as the decimal point and .period as the separator. "l" depends on the locale to determine the characters to use as the decimal point and the separator. The optional places determines the number of digits after the decimal point. The default is determined by the format, as seen in the table. If the places is 0, then the number of decimal places will be the fewest to exactly display the number without truncating. If the places is larger, then the field is padded if necessary with trailing 0. The optional separation determines the spacing of the separator character. For example, to place a separator between billions, millions, and thousands (that is, every 3 digits) then separation should be 3. If separation is zero, then there is no separation. The default is determined by the style. integer style base default separation minimum places separator i integer 10 0 1 _underbar b binary 2 o octal 8 h hexadecimal 16 t Base32 32 The integer styles first trunc the number. The fractional part of the number is ignored. The separation character is _underbar. The optional places determines the minimum number of digits to show. More leading 0 may be shown if necessary. The default is determined by the format, as seen in the table. The optional separation determines the spacing of the separator character. For example, to place a separator between billions, millions, and thousands (that is, every 3 digits) then separation should be 3. If separation is zero, then there is no separation. The default is determined by the format, as seen in the table. Examples: def data: 0123456789.1 assign result: text(data) # result is "123456789.1" assign result: text(data, "n") # result is "123456789.1" assign result: text(data, "3s4") # result is "123 456 789.1000" assign result: text(data, "s") # result is "123 456 789.1" assign result: text(data, "d2") # result is "123,456,789.10" assign result: text(data, "4d0") # result is "1,2345,6789.1" assign result: text(data, "v2") # result is "123.456.789,10" assign result: text(data, "e") # result is "1.234567891e8" assign result: text(data, "e4") # result is "1.2345e8" assign result: text(data, "i") # result is "123456789" assign result: text(data, "8b") # result is "111_01011011_11001101_00010101" assign result: text(data, "o") # result is "726746425" assign result: text(data, "h") # result is "75BCD15" assign result: text(data, "t") # result is "3NQK8N" assign result: text(12) # result is "12" assign result: text(12, 8) # result is "14" assign result: text(12, 32) # result is "C" assign result: text(12, "4b8") # result is "0000_1100" assign result: text(12, "o3") # result is "014" assign result: text(12, "h4") # result is "000C" assign result: text(12, "t2") # result is "0C" text(text) Return the text. The text is not altered. text(text, from, to) Make a copy of part of a text. text: the text to copy. from: the position at which to start copying. Default: 0, the beginning. If negative, add length(text). to: the position at which to stop copying. Default: length(text), the end. If negative, add length(text). If, after adjustment, from and to are not valid integers in the proper range, then it returns null. from must be positive and less than or equal to to. to must be less than or equal to length(text). assign my_text: "miskatonic" text(my_text, 0, 3) # "mis" # the first 3 text(my_text, 3, 6) # "kat" # from 3 to 6 text(my_text, 5) # "tonic" # exclude the first 5 text(my_text, 0, -4) # "miskat" # exclude the last 4 text(my_text, -3) # "nic" # the last 3 text(my_text, 0, 0) # "" text(my_text, 10) # "" text(my_text, 11) # null text(my_text, 2, 1) # null Sensory Functions The sensory functions end with ?question mark. They always return a logical value. actor?(value) Is the value an actor address object? actor?(me!) # true actor?("actor") # false actor?({actor: true}) # false array?(value) Is the value an array? If the value is an array, the result is true. Otherwise, the result is false. array?(0) # false array?({}) # false array?([]) # true not(array?([])) # false array?(pattern (1- {letter digit "_-%"})) # false array?(null) # false array?("array") # false blob?(value) Is the value a blob? If the value is a blob, the result is true. Otherwise, the result is false. blob?(0) # false blob?("blob") # false blob?(blob()) # true character?(value) Is the value a character? If the value is a text with a length of 1, then the result is true. Otherwise, the result is false. character?(1) # false character?("1") # true character?("character") # false character?("") # false character?("\u{FFFE}") # true character?() # false character?("/q") # false character?("\q") # true character?(<<">>) # true character?(null) # false data?(value) Is the value data? If the value is a text, number, logical, array, blob, or record, then the result is true. If the value is a function, pattern, or null, the result is false. data?(0) # true data?("") # true data?(["0"]) # true data?({}) # true data?(null) # false digit?(value) Is the value a digit? If the value is a text with a length of 1 and is one of the 10 digit characters, then the result is true. Otherwise, the result is false. digit?(0) # false digit?("0") # true digit?("9") # true digit?("09") # false digit?("digit") # false digit?("") # false digit?(1) # false digit?(["0"]) # false digit?("Z") # false false?(value) Is the value false? fit?(number) Is the number a fit number? A number is a fit number if it is an integer that fits in 56 bits. All fit numbers are integers in the range -36028797018963968 thru 36028797018963967. Only fit numbers can be given to the fit functions. Misty has additional integers that are too big to fit. function?(value) Is the value a function? If the value is a function, then the result is true. Otherwise, the result is false. function?(0) # false function?(function () (null)) # true function?("function") # false function?(null) # false function?(function?) # true integer?(value) Is the value an integer? If the value is a number and if its fraction part is zero, then the result is true. Otherwise, the result is false. integer?(0) # true integer?(13 / 4) # false integer?(16 / 4) # true integer?(65.0000000) # true integer?(65.0000001) # false integer?(null) # false integer?(true) # false integer?(1) # true integer?(36028797018963968) # true integer?(1.00001e100) # true letter?(value) Is the value a letter? If the value is a text with a length of 1 and is a letter, then the result is true. Otherwise, the result is false. letter?(0) # false letter?("0") # false letter?("letter") # false letter?("l") # true letter?("L") # true letter?("") # false letter?(null) # false logical?(value) Is the value a logical? A logical is either a false or a true. All other values are not logical. logical?(false) # true logical?(true) # true logical?(0) # false logical?() # false logical?(null) # false lower?(value) Is the value a lower case letter? If the value is a text with a length of 1 and is a lower case letter, then the result is true. Otherwise, the result is false. lower?(0) # false lower?("0") # false lower?("lower") # false lower?("l") # true lower?("L") # false lower?("") # false null?(value) Is the value null? This does the same thing as value = null. number?(value) Is the value a number? If the value is a number, then the result is true. Otherwise, the result is false. number?(0) # true number?((13 / 4)) # true number?((13 / 0)) # false number?(98.6) # true number?("0") # false number?(1) # true pattern?(value) Is the value a pattern? If the value is a pattern, then the result is true. Otherwise, the result is false. pattern?(pattern (1- {letter digit "_-%"})) # true record?(value) Is the value a record? If the value is a record, then the result is true. Otherwise, the result is false. record?(0) # false record?({}) # true record?([]) # false record?("record") # false record?("{}") # false record?(function () ({})) # false record?(pattern (1- {letter digit "_-%"})) # false record?(@) # true stone?(value) Is the value stone? stone?("false") # true stone?(9) # true stone?(null) # true stone?({}) # false stone?(stone({})) # true text?(value) Is the value a text? If the value is a text, then the result is true. Otherwise, the result is false. text?(0) # false text?("0") # true text?("number") # true text?("") # true text?(null) # false true?(value) Is the value true? upper?(value) Is the value an upper case letter? If the value is a text with a length of 1 and is an upper case letter, then the result is true. Otherwise, the result is false. upper?(0) # false upper?("0") # false upper?("UPPER") # false upper?("u") # false upper?("U") # true upper?("") # false whitespace?(value) Is the value whitespace? If the value is a nonempty text containing only whitespace characters, then the result is true. Otherwise, the result is false. whitespace?(0) # false whitespace?(32) # false whitespace?(char(32)) # true whitespace?("0") # false whitespace?(" ") # true whitespace?("\t") # true whitespace?("\r") # true whitespace?("\r\n") # true whitespace?("space") # false whitespace?(" ") # true whitespace?(" L") # false whitespace?("") # false Standard Functions abs(number) Absolute value. Return the positive form of the number. If the input value is not a number, the result is null. apply(function, array) Apply. Execute the function and return its return value. Pass the elements of the array as input values. See proxy. If the first input value is not a function, apply returns its first input value. If length(array) is greater than length(function), it disrupts. If the second argument is not an array, it is used as a single input value. ceiling(number, place) If place is 0 or null, the number is rounded up to the smallest integer that is greater than or equal to the number. If place is a small positive integer, then the number is rounded up to that decimal place. Examples: assign result: ceiling(12.3775) # result is 13 assign result: ceiling(12.3775, 0) # result is 13 assign result: ceiling(12.3775, 1) # result is 20 assign result: ceiling(12.3775, -2) # result is 12.38 assign result: ceiling(-12.3775, -2) # result is -12.37 assign result: ceiling(-12.3775) # result is -12 character(value) If the value is a text, it returns the first character. If the value is a non-negative 32-bit integer, it returns the character from that codepoint. Otherwise, it returns the empty string. codepoint(text) The codepoint function returns the codepoint number of the first character of the text. If the input value is not a text, or if it is the empty text, then it returns null. extract(text, pattern, from, to) The text is matched to the pattern. If it does not match, the result is null. If the pattern does match, then the result is a record containing the saved fields. fallback(requestor_array) The fallback requestor factory returns a requestor function that tries each of the requestors in the requstor_array until it gets a success. When the requestor is called, it calls the first requestor in requestor_array. If that is eventually successful, its value is passed to the callback. But if that requestor fails, the next requestor is called, and so on. If none of the requestors is successful, then the fallback fails. If any one succeeds, then the fallback succeeds. The fallback requestor returns a cancel function that can be called when the result is no longer needed. filter(array, function) The filter function calls a function for every element in the array, passing each element and its element number. (element, element_nr) When the function's return value is true, then the element is copied into a new array. If the function's return value is false, then the element is not copied into the new array. If the return value is not a logical, then the filter returns null. It returns a new array. The length of the new array is between 0 thru length(array). It returns null if the function input is not a function. Example: def data: [0, 1.25, 2, 3.5, 4, 5.75] def integers: filter(data, integer?) # integers is [0, 2, 4] find(array, function, reverse, from) Call the function for each element of the array, passing each element and its element number. (element, element_nr) If the function returns true, then find returns the element number of the current element. If the second input value is not a function, then it is compared exactly to the elements. If the reverse input value is true, then search begins at the end of the array and works backward. The from input value gives the element number to search first. The default is 0 unless reverse is true, when the default is length(array) - 1. find returns the element number of the found value. If nothing is found, find returns null. floor(number, place) If place is 0 or null, the number is rounded down to the greatest integer that is less than or equal to the number. If place is a small positive integer, then the number is rounded down to that many decimal places. For positive numbers, this is like discarding decimal places. Examples: assign result: floor(12.3775) # result is 12 assign result: floor(12.3775, -2) # result is 12.37 assign result: floor(-12.3775, 0) # result is -13 assign result: floor(-12.3775, -2) # result is -12.38 for(array, function, reverse, exit) For each. Call the function with each element of the array. The function is passed each element and its element number. (element, element_nr) If reverse is true, then it starts with the last element and works backwards. If exit is not null, then when the function returns the exit value, then the for function returns early. The exit value is usually true or false, but it may be anything. If exit is null, then every element is processed. The for function returns null unless it did an early exit, when it returns the exit value. format(text, collection, transformer) The format function makes a new text with substitutions in an original text. A collection is either an array of texts or a record of texts. A search is made for {left brace and }right brace in the text. If they are found, the middle text between them is examined. If the collection is an array, the middle text is used as a number, and then the matched {left brace and middle and }right brace are replaced with the text at that subscript in the array. If the collection is a record, and if the middle text is the key of a member of the collection with a text value, then the value of the member is used in the substitution. Unmatched text is not altered. The text between {left brace and }right brace is broken on the :colon character. The left text will be used as a number or name to select a value from the collection. (The value need not be a text.) If a transformer input is a function, then it is called with the collection[left text] and right text as inputs. If it returns a text, then the substitution is made. If a transformer input is a record, then the right text is used to select a function from the transformer. That function is passed the value from the collection. If the return value is a text, that text will substitute. If there is no colon, then the empty text is used to select the function from the transformer. If the transformer does not produce a function, or if the function does not return a text, then no replacement occurs. If transformer[right text](collection[left text]) produces a text, then the substitution is made. If the substitution is not made, and if collection[left text] is a number, then the right text is used as a format input in calling collection[left text].text(right text). If it returns a text, then the substitution is made. Example: var result: format("{0} in {1}!", ["Malmborg", "Plano"]) # result is "Malmborg in Plano!" fraction(number) The fraction function returns the fractional part of a number It returns null for non-numbers. Also see whole. length(value) The length function value result array number of elements blob number of bits logical null function number of named inputs null null number null record record.length() text number of codepoints Length. Find the length of an array in elements, a blob in bits, or a text in codepoints. For functions, it is the arity (or number of inputs). If the value is a record containing a length field If the length field contains a function, then length(my_record) has the same effect as my_record.length(). If the length field contains a number, return the number. All other values produce null. lower(text) The lower function returns a text in which all uppercase characters are converted to lowercase. Example: assign result: lower("Carl Hollywood") # result is "carl hollywood" max(number, number) Maximum. The result is the larger of the two numbers. If either input value is not a number, the result is null. max(3, 4) # 4 max can be used with min to constrain values within an acceptable range. min(max(2, 3), 7) # 3 min(max(4, 3), 7) # 4 min(max(8, 3), 7) # 7 max(1, null) # null max(null, 1) # null min(number,number) Minimum. The result is the smaller of the two numbers. If either input value is not a number, the result is null. min(3, 4) # 3 modulo(dividend, divisor) The result of modulo(dividend, divisor) is dividend - (divisor * floor(dividend / divisor)). The result has the sign of the divisor. If dividend is 0, then the result is 0. If divisor is 0, or if either operand is not a number, then the result is null. dividend and divisor are not required to be integers. If both input values are integers, and if the divisor is a positive power of two, then it is the same as and(dividend, divisor - 1). neg(number) Negate. Reverse the sign of a number. If the input value is not a number, the result is null. Note that the -minus sign is not used as a prefix negation operator. normalize(text) Unicode normalize. Return a text whose textual value is the same as text, but whose binary representation is in the specified Unicode normalization form. The two texts will display the same, but might not be equal. not(logical) Not. Return the opposite logical. If the input value is not a logical, it returns null. parallel(requestor_array, throttle, need) Parallel. The parallel requestor factory returns a resquestor function. When the requestor function is called with a callback function and a value, every requestor in the requestor_array is called with the value, and the results are placed in corresponding elements of the results array. This all happens in parallel. The value produced by the first element of the requestor_array provides the first element of the result. The completed results array is passed to the callback function. By default, it starts all of the requestors in the requestor_array at once, each in its own turn so that they do not interfere with each other. This can shock some systems by unleashing a lot of demand all at once. To mitigate the shock, the optional throttle argument sets the maximum number of requestors running at a time. As requestors succeed or fail, waiting requestors can be started. The throttle is optional. If provided, the throttle is a number: the maximum number of requestors to have running at any time. Ordinarily, the number of successes must be the same as the number of requestors in the requestor_array. If you need few successes, specify your need with the need argument. The need could be 1, meaning that 1 or more successes are needed. The need could be 0, meaning that no successes are needed. If the number of successes is greater than or equal to need, then the whole operation succeeds. The need must be between 0 and requestor_array.length. The requestor function itself returns a cancel function that cancels all of the pending requestors from the requestor_array. race(requestor_array, throttle, need) Race. The race function is a requestor factory that takes an array of requestor functions and returns a requestor function that starts all of the requestors in the requestor_array at once. By default, it starts all of the requestors in the requestor_array at once, each in its own turn so that they do not interfere with each other. This can shock some systems by unleashing a lot of demand at once. To mitigate the shock, the optional throttle argument sets the maximum number of requestors running at a time. As requestors succeed or fail, waiting requestors can be started. By default, a single result is produced. If an array of results is need, specify the needed number of results in the need parameter. When the needed number of successful results is obtained, the operation ends. The results go into a sparce array aligned with the requestor_array, and unfinished requestors are cancelled. The need argument must be between 1 and requestor_array.length. The returned requestor function returns a cancel function that cancels all of the pending requestors from the requestor_array. reduce(array, function, initial, reverse) Reduce. The reduce function takes a function that takes two input values and returns a value. function (first, second) { return ... } The function is called for each element of the array, passing the result of the previous iteration to the next iteration. The initial value is optional. If present, the function is called for every element of the array. If initial is null: If length(array) is 0, then it returns null. If length(array) is 1, then it returns array[0]. If length(array) is 2, it returns function(array[0], array[1]). If length(array) is 3, it returns function(function(array[0], array[1]), array[2]). And so on. If initial is not null: If length(array) is 0, then it returns initial. If length(array) is 1, then it returns function(initial, array[0]). If length(array) is 2, it returns function(function(initial, array[0]), array[1]). If length(array) is 3, it returns function(function(function(initial, array[0]), array[1]), array[2]). And so on. If reverse is true, then the work begins at the end of the array and works backward. Example: def data: [1, 2, 3, 4, 5, 6, 7, 8, 9] def total: reduce(data, '+) # total is 45 def product: reduce(data, '*) # product is 362880 remainder(dividend, divisor) Remainder. For fit integers, the remainder is dividend - ((dividend // divisor) * divisor). replace(text, target, replacement, limit) Return a new text in which the target is replaced by the replacement. text: the source text. target: a text or pattern that should be replaced in the source. replacement: text to replace the matched text, or a function that takes the matched text and the starting position, and returns the replacement text or null if it should be left alone. limit: The maximum number of replacements. The default is all possible replacements. The limit includes null matches. reverse(array) The reverse function makes a new array or blob with the elements or bits in the opposite order. It returns a new, reversed array or blob. Example: def data: ["I", "am", "Sam"] def result: reverse(data) # the result is ["Sam", "am", "I"] round(number, place) If place is 0 or null, the number is rounded to the nearest integer. If place is a small integer, then the number is rounded to that many decimal places. Examples: round(12.3775) # 12 round(12.3775, -2) # 12.38 round(-12.3775, 0) # -12 round(-12.3775, 1) # -10 round(-12.3775, 2) # 0 round(-12.3775, -2) # -12.38 search(text, target, from) Search the text for the target. If the target is found, return the character position of the left-most part of the match. If the search fails, return null. text: the source text. target: a text or pattern that should be found in the source. from: The starting position for the search. The default is 0, the beginning of the text. If from is negative, it is added to length(text). sequence(requestor_array) Sequence. The sequence requestor factory that takes a requestor_array and returns a requestor function that starts all of the requestors in the requestor_array one at a time. The result of each becomes the input to the next. The last result is the result of the sequence. sequence returns a requestor that returns a cancel function and processes each requestor in requestor_array one at a time. Each of those requestors is passed the result of the previous requestor as its value argument. If all succeed, then the sequence succeeds, giving the result of the last of the requestors. If any fail, then the sequence fails.The sequence succeeds if every requestor in the requestor_array succeeds sign(number) The sign function returns -1 if the number is negative, 0 if the number is exactly 0, 1 if the number is positive, and null if it is not a number. sort(array, select) The sort function produces a new array in which the values are sorted. Sort keys must be either all numbers or all texts. Any other type of key or any error in the key calculation will cause the sort to fail, returning null. The sort is ascending. The sort is stable, so the relative order of equal keys is preserved. The optional select input determines how the sort key for each element is selected. select type Sort key for array[index] Description null array[index] The sort key is the element itself. This is useful for sorting simple arrays of numbers or texts. text array[index][select] The sort key is the select field of each record element. This is useful for sorting arrays of records. number array[index][select] The sort key is the select element of each array element. This is useful for sorting arrays of arrays. array select[index] select is an array of the same length containing the sort keys. It returns a new, sorted array. Examples: def foods: ["oats", "peas", "beans", "barley"] def result: sort(foods) # result is ["barley", "beans", "oats", "peas"] var stooges: [ {first: "Moe", last: "Howard"} {first: "Joe", last: "DeRita"} {first: "Shemp", last: "Howard"} {first: "Larry", last: "Fine"} {first: "Joe", last: "Besser"} {first: "Curly", last: "Howard"} ] assign stooges: sort(sort(stooges, "first"), "last") # stooges is now [ # {first: "Joe", last: "Besser"} # {first: "Joe", last: "DeRita"} # {first: "Larry", last: "Fine"} # {first: "Curly", last: "Howard"} # {first: "Moe", last: "Howard"} # {first: "Shemp", last: "Howard"} # ] assign stooges: sort(stooges, [50, 60, 20, 40, 10, 30]) # stooges is now [ # {first: "Moe", last: "Howard"} # {first: "Larry", last: "Fine"} # {first: "Shemp", last: "Howard"} # {first: "Curly", last: "Howard"} # {first: "Joe", last: "Besser"} # {first: "Joe", last: "DeRita"} # ] stone(value) Petrify the value, turning it into stone. Its contents are preserved, but it can no longer be modified by the assign statement or the blob.write functions. This is usually performed on arrays, records, and blobs. All other types are already stone. Attempting to turn a value that is stone to stone will have no effect. The stone operation is deep. Any mutable objects in the value will also be turned to stone. This can not be reversed. Immutable objects can never become mutable. A mutable copy can be made of an immutable object, but the original object remains immutable. The stone function returns the value. trim(text, reject) The trim function removes selected characters from the ends of a text. The default is to remove control characters and spaces. assign result: " Hello there ".trim() # result is "Hello there" trunc(number, place) The number is truncated toward zero. If the number is positive, the result is the same as floor(place). If the number is negative, the result is the same as ceiling(place). If place is a small integer, then the number is rounded down to that many decimal places. This is like discarding decimal places. Examples: assign result: trunc(12.3775, 0) # result is 12 assign result: trunc(12.3775, 2) # result is 12.37 assign result: trunc(-12.3775) # result is -12 assign result: trunc(-12.3775, 2) # result is -12.37 turkish_lower(text) Similar to lower, except that I goes to ıdotless i. turkish_upper(text) Similar to upper, except that i goes to İI dot. upper(text) The upper function returns a text in which all lowercase characters are converted to uppercase. Example: assign result: upper("Carl Hollywood") # result is "CARL HOLLYWOOD" whole(number) The whole function returns the whole part of a number. It returns null for non-numbers. Also see fraction.