docs » hs.fnutils
Functional programming utility functions
- Functions - API calls offered directly by the extension
- concat
- contains
- copy
- each
- every
- filter
- find
- ieach
- ifilter
- imap
- indexOf
- map
- mapCat
- reduce
- some
- split
- Constructors - API calls which return an object, typically one that offers API methods
- cycle
- partial
- sequence
- sortByKeys
- sortByKeyValues
Signature | hs.fnutils.concat(table1, table2) |
---|---|
Type | Function |
Description | Join two tables together |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.contains(table, element) -> bool |
---|---|
Type | Function |
Description | Determine if a table contains a given object |
Parameters |
|
Returns |
|
Signature | hs.fnutils.copy(table) -> table |
---|---|
Type | Function |
Description | Copy a table using pairs() |
Parameters |
|
Returns |
|
Signature | hs.fnutils.each(table, fn) |
---|---|
Type | Function |
Description | Execute a function across a table (in arbitrary order), and discard the results |
Parameters |
|
Returns |
|
Signature | hs.fnutils.every(table, fn) -> bool |
---|---|
Type | Function |
Description | Returns true if the application of fn on every entry in table is true. |
Parameters |
|
Returns |
|
Signature | hs.fnutils.filter(table, fn) -> table |
---|---|
Type | Function |
Description | Filter a table by running a predicate function on its elements (in arbitrary order) |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.find(table, fn) -> element |
---|---|
Type | Function |
Description | Execute a function across a table and return the first element where that function returns true |
Parameters |
|
Returns |
|
Signature | hs.fnutils.ieach(list, fn) |
---|---|
Type | Function |
Description | Execute a function across a list-like table in order, and discard the results |
Parameters |
|
Returns |
|
Signature | hs.fnutils.ifilter(list, fn) -> list |
---|---|
Type | Function |
Description | Filter a list-like table by running a predicate function on its elements in order |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.imap(list, fn) -> list |
---|---|
Type | Function |
Description | Execute a function across a list-like table in order, and collect the results |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.indexOf(table, element) -> number or nil |
---|---|
Type | Function |
Description | Determine the location in a table of a given object |
Parameters |
|
Returns |
|
Signature | hs.fnutils.map(table, fn) -> table |
---|---|
Type | Function |
Description | Execute a function across a table (in arbitrary order) and collect the results |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.mapCat(table, fn) -> table |
---|---|
Type | Function |
Description | Execute, across a table, a function that outputs tables, and concatenate all of those tables together |
Parameters |
|
Returns |
|
Signature | hs.fnutils.reduce(table, fn) -> table |
---|---|
Type | Function |
Description | Reduce a table to a single element, using a function |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.some(table, fn) -> bool |
---|---|
Type | Function |
Description | Returns true if the application of fn on entries in table are true for at least one of the members. |
Parameters |
|
Returns |
|
Signature | hs.fnutils.split(sString, sSeparator [, nMax] [, bPlain]) -> { array } |
---|---|
Type | Function |
Description | Convert string to an array of strings, breaking at the specified separator. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.cycle(table) -> fn() |
---|---|
Type | Constructor |
Description | Creates a function that repeatedly iterates a table |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.partial(fn, ...) -> fn' |
---|---|
Type | Constructor |
Description | Returns a new function which takes the provided arguments and pre-applies them as the initial arguments to the provided function. When the new function is later invoked with additional arguments, they are appended to the end of the initial list given and the complete list of arguments is finally passed into the provided function and its result returned. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.sequence(...) -> fn |
---|---|
Type | Constructor |
Description | Creates a function that will collect the result of a series of functions into a table |
Parameters |
|
Returns |
|
Signature | hs.fnutils.sortByKeys(table[ , function]) -> function |
---|---|
Type | Constructor |
Description | Iterator for retrieving elements from a table of key-value pairs in the order of the keys. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.fnutils.sortByKeyValues(table[ , function]) -> function |
---|---|
Type | Constructor |
Description | Iterator for retrieving elements from a table of key-value pairs in the order of the values. |
Parameters |
|
Returns |
|
Notes |
|