AFL
Arguably Functional Language
AFL Documentation
Util Component
This entry contains descriptions for all normal functions that are part of the Util component.
Functions
util.checkParam(4)
Parameters: value toCheck, type checkAgainst, val parameter, string funct
-
Description: checkParam is intended to make robust type checks in functions easier. toCheck is the parameter of your function you want to check, checkAgainst is the type you expect it to be, parameter is some identifier of the parameter (usually a char that matches it's index in params) and funct is the name of your function.
if the value is correct, checkParam returns it. if it is not, it will happily throw up a reasonably formatted error. you could imagine it being used like so:
number =checkParam( arrayGet(params 0) num '0' "numberFunction");
Returns: value
util.not(1)
Parameters: bool b
Description: negates b.
Returns: bool
util.numInput(0)
Parameters: none
Description: Prompts the user for a number, and will not stop prompting the user until a num value is entered. Returns this value.
Returns: num
util.isWhitespace(1)
Parameters: char ch
Description: if ch is ' ' or '\n', returns true. Otherwise, returns false.
Returns: bool
util.fromCharArray(1)
Parameters: array arr
Description: if arr consists only of char values, it will return a string of all of the values concatenated together.
Returns: string
util.strip(1)
Parameters: string str
Description: returns str, but remove any leading or trailing whitespace. (' ' or '\n' characters)
Returns: str
util.length(1)
Parameters: string str
Description: returns the number of characters in str.
Returns: num
util.substring(3)
Parameters: string str, num start, num end
Description: returns a section of str from index start (inclusive) to index end (exclusive).
Returns: str
util.split(2)
Parameters: string str, char splitBy
Description: Returns an array where every instance of splitBy in str creates a new element.
Returns: array
util.contains(2)
Parameters: string str, char c
Description: Returns true if at least one instance of c is in str, false otherwise.
Returns: bool