#
hs.fnutils
Functional programming utility functions
#
API Overview
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
#
API Documentation
#
Functions
#
concat
Signature | hs.fnutils.concat(table1, table2) |
Type | Function |
Description | Join two tables together |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 190 |
#
contains
Signature | hs.fnutils.contains(table, element) -> bool |
Type | Function |
Description | Determine if a table contains a given object |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 152 |
#
copy
Signature | hs.fnutils.copy(table) -> table |
Type | Function |
Description | Copy a table using pairs() |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 135 |
#
each
Signature | hs.fnutils.each(table, fn) |
Type | Function |
Description | Execute a function across a table (in arbitrary order), and discard the results |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 76 |
#
every
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 |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 356 |
#
filter
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 112 |
#
find
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 |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 261 |
#
ieach
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 |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 62 |
#
ifilter
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 91 |
#
imap
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 10 |
#
indexOf
Signature | hs.fnutils.indexOf(table, element) -> number or nil |
Type | Function |
Description | Determine the location in a table of a given object |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 171 |
#
map
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 37 |
#
mapCat
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 |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 210 |
#
reduce
Signature | hs.fnutils.reduce(table, fn[, initial]) -> table |
Type | Function |
Description | Reduce a table to a single element, using a function |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 228 |
#
some
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 |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 374 |
#
split
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 472 |
#
Constructors
#
cycle
Signature | hs.fnutils.cycle(table) -> fn() |
Type | Constructor |
Description | Creates a function that repeatedly iterates a table |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 330 |
#
partial
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 298 |
#
sequence
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 |
|
Notes | None |
Examples | None |
Source | extensions/fnutils/fnutils.lua line 278 |
#
sortByKeys
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 392 |
#
sortByKeyValues
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 |
|
Examples | None |
Source | extensions/fnutils/fnutils.lua line 432 |