2,875
edits
(Created page with "Contains all shorthand functions that convert one Enumerable object into another. Most of these functions can be chained together to result in a state machine that captures all of the applied functions. The state machine is only executed once a pairs or ipairs operator is applied to the state machine, or by manually progressing the Module:FunList/Enumerator.") |
No edit summary |
||
Line 1: | Line 1: | ||
Contains all shorthand functions that convert one Enumerable object into another. Most of these functions can be chained together to result in a state machine that captures all of the applied functions. The state machine is only executed once a pairs or ipairs operator is applied to the state machine, or by manually progressing the [[Module:FunList/Enumerator]]. | Contains all shorthand functions that convert one Enumerable object into another. Most of these functions can be chained together to result in a state machine that captures all of the applied functions. The state machine is only executed once a pairs or ipairs operator is applied to the state machine, or by manually progressing the [[Module:FunList/Enumerator]]. | ||
<onlyinclude> | |||
== Functions == | |||
=== all === | |||
<syntaxhighlight lang="lua"> | |||
-- Determines whether all elements of a sequence satisfy a condition. | |||
---@param self Enumerable | |||
---@param predicate fun(item: any): boolean | |||
---@return boolean | |||
function Enumerable:all(predicate) | |||
</syntaxhighlight> | |||
=== any === | |||
<syntaxhighlight lang="lua"> | |||
-- Determines whether any element of a sequence exists or satisfies a condition. | |||
---@param self Enumerable | |||
---@param predicate fun(item: any): boolean | |||
---@return boolean | |||
function Enumerable:any(predicate) | |||
</syntaxhighlight> | |||
=== append === | |||
<syntaxhighlight lang="lua"> | |||
-- Adds an item to the end of the enumerable. | |||
---@param self Enumerable | |||
---@param item any | |||
function Enumerable:append(item) | |||
</syntaxhighlight> | |||
=== prepend === | |||
<syntaxhighlight lang="lua"> | |||
-- Adds an item to the front of the enumerable. | |||
---@param self Enumerable | |||
---@param item any | |||
function Enumerable:prepend(item) | |||
</syntaxhighlight> | |||
=== contains === | |||
<syntaxhighlight lang="lua"> | |||
-- Determines whether a sequence contains a specified element. | |||
---@param self Enumerable | |||
---@param item any | |||
---@return boolean | |||
function Enumerable:contains(item) | |||
</syntaxhighlight> | |||
=== count === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the number of elements in a sequence. | |||
---@param self Enumerable | |||
---@return integer | |||
function Enumerable:count() | |||
</syntaxhighlight> | |||
=== first === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the first element of a sequence. | |||
---@param self Enumerable | |||
---@param predicate? fun(item: any): boolean | |||
---@return any | |||
function Enumerable:first(predicate) | |||
</syntaxhighlight> | |||
=== firstOrDefault === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the first element of a sequence, or a default value if no element is found. | |||
---@param self Enumerable | |||
---@param predicate? fun(item: any): boolean | |||
---@param defaultItem? any | |||
---@return any | |||
function Enumerable:firstOrDefault(predicate, defaultItem) | |||
</syntaxhighlight> | |||
=== last === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the last element of a sequence. | |||
---@param self Enumerable | |||
---@return any | |||
function Enumerable:last() | |||
</syntaxhighlight> | |||
=== lastOrDefault === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the last element of a sequence, or a default value if no element is found. | |||
---@param self Enumerable | |||
---@param defaultItem? any | |||
---@return any | |||
function Enumerable:lastOrDefault(defaultItem) | |||
</syntaxhighlight> | |||
=== max === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the maximum value in a sequence of values. | |||
---@param self Enumerable | |||
---@return number | |||
function Enumerable:max() | |||
</syntaxhighlight> | |||
=== min === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the minimum value in a sequence of values. | |||
---@param self Enumerable | |||
---@return number | |||
function Enumerable:min() | |||
</syntaxhighlight> | |||
=== sum === | |||
<syntaxhighlight lang="lua"> | |||
-- Returns the sum value of a sequence of values. | |||
function Enumerable:sum() | |||
</syntaxhighlight> | |||
=== concat === | |||
<syntaxhighlight lang="lua"> | |||
-- Adds elements from one sequence to the other. | |||
---@param self Enumerable | |||
---@param other Enumerable | |||
function Enumerable:concat(other) | |||
</syntaxhighlight> | |||
=== difference === | |||
<syntaxhighlight lang="lua"> | |||
-- Gets the difference between two sequences | |||
---@param self Enumerable | |||
---@param other Enumerable | |||
function Enumerable:difference(other) | |||
</syntaxhighlight> | |||
=== differenceBy === | |||
<syntaxhighlight lang="lua"> | |||
-- Gets the difference between two sequences based on a key | |||
---@param self Enumerable | |||
---@param keySelector? fun(value: any, index: any): any | |||
function Enumerable:differenceBy(other, keySelector) | |||
</syntaxhighlight> | |||
=== flatMap === | |||
<syntaxhighlight lang="lua"> | |||
-- Maps items from one sequence to another. | |||
---@param self Enumerable | |||
---@param selector fun(value: any, index: integer): any | |||
function Enumerable:flatMap(selector) | |||
</syntaxhighlight> | |||
=== groupBy === | |||
<syntaxhighlight lang="lua"> | |||
--Groups the elements of a sequence. | |||
---@param self Enumerable | |||
---@param keySelector fun(param: any): any | |||
---@param elementSelector? fun(param: any): any | |||
function Enumerable:groupBy(keySelector, elementSelector) | |||
</syntaxhighlight> | |||
=== groupByResult === | |||
<syntaxhighlight lang="lua"> | |||
--Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. | |||
---@param self Enumerable | |||
---@param keySelector fun(param: any): any | |||
---@param elementSelector? fun(param: any): any | |||
---@param resultSelector fun(key: any, grouping: Grouping): any | |||
function Enumerable:groupByResult(keySelector, elementSelector, resultSelector) | |||
</syntaxhighlight> | |||
=== intersect === | |||
<syntaxhighlight lang="lua"> | |||
--Produces the set intersection of two sequences. | |||
---@param self Enumerable | |||
---@param other Enumerable | |||
function Enumerable:intersect(other) | |||
</syntaxhighlight> | |||
=== intersectBy === | |||
<syntaxhighlight lang="lua"> | |||
--Produces the set intersection of two sequences according to a specified key selector function. | |||
---@param self Enumerable | |||
---@param other Enumerable | |||
---@param keySelector? fun(value: any, index: any): any | |||
function Enumerable:intersectBy(other, keySelector) | |||
</syntaxhighlight> | |||
=== map === | |||
<syntaxhighlight lang="lua"> | |||
--Projects each element of a sequence into a new form. | |||
---@param self Enumerable | |||
---@param selector fun(value: any, index: any): any | |||
function Enumerable:map(selector) | |||
</syntaxhighlight> | |||
=== sort === | |||
<syntaxhighlight lang="lua"> | |||
--Sorts a sequence. | |||
---@param self Enumerable | |||
---@return SortableIterator | |||
function Enumerable:sort() | |||
</syntaxhighlight> | |||
=== sortDescending === | |||
<syntaxhighlight lang="lua"> | |||
--Sorts a sequence in descending order. | |||
---@param self Enumerable | |||
---@return SortableIterator | |||
function Enumerable:sortDescending() | |||
</syntaxhighlight> | |||
=== sortBy === | |||
<syntaxhighlight lang="lua"> | |||
--Sorts a sequence based on a specified key selector function. | |||
---@param self Enumerable | |||
---@return SortableIterator | |||
function Enumerable:sortBy(keySelector) | |||
</syntaxhighlight> | |||
=== sortByDescending === | |||
<syntaxhighlight lang="lua"> | |||
--Sorts a sequence based on a specified key selector function in descending order. | |||
---@param self Enumerable | |||
---@return SortableIterator | |||
function Enumerable:sortByDescending(keySelector) | |||
</syntaxhighlight> | |||
=== thenSortBy === | |||
<syntaxhighlight lang="lua"> | |||
--Sorts a sorted sequence further based on a specified key selector function. | |||
---@param self SortableIterator | |||
---@return SortableIterator | |||
function Enumerable:thenSortBy(keySelector) | |||
</syntaxhighlight> | |||
=== thenSortByDescending === | |||
<syntaxhighlight lang="lua"> | |||
--Sorts a sorted sequence further based on a specified key selector function in descending order. | |||
---@param self SortableIterator | |||
---@return SortableIterator | |||
function Enumerable:thenSortByDescending(keySelector) | |||
</syntaxhighlight> | |||
=== union === | |||
<syntaxhighlight lang="lua"> | |||
--Produces the set union of two sequences according to a specified key selector function. | |||
---@param self Enumerable | |||
---@param other any | |||
function Enumerable:union(other) | |||
</syntaxhighlight> | |||
=== unionBy === | |||
<syntaxhighlight lang="lua"> | |||
--Produces the set union of two sequences according to a specified key selector function. | |||
---@param self Enumerable | |||
---@param other any | |||
---@param keySelector? fun(value: any, index: any): any | |||
function Enumerable:unionBy(other, keySelector) | |||
</syntaxhighlight> | |||
=== unique === | |||
<syntaxhighlight lang="lua"> | |||
--Returns unique (distinct) elements from a sequence according to a specified key selector function. | |||
---@param self Enumerable | |||
function Enumerable:unique() | |||
</syntaxhighlight> | |||
=== uniqueBy === | |||
<syntaxhighlight lang="lua"> | |||
--Returns unique (distinct) elements from a sequence according to a specified key selector function. | |||
---@param self Enumerable | |||
---@param keySelector? fun(value: any, index: any): any | |||
function Enumerable:uniqueBy(keySelector) | |||
</syntaxhighlight> | |||
=== where === | |||
<syntaxhighlight lang="lua"> | |||
--Filters a sequence of values based on a predicate. | |||
---@param self Enumerable | |||
---@param predicate fun(value: any, index: any): boolean | |||
function Enumerable:where(predicate) | |||
</syntaxhighlight> | |||
=== zip === | |||
<syntaxhighlight lang="lua"> | |||
--Projects each element of a sequence to an Enumerable and flattens the resulting sequences into one sequence. | |||
---@param self Enumerable | |||
---@param other any | |||
function Enumerable:zip(other) | |||
</syntaxhighlight> | |||
=== zipBy === | |||
<syntaxhighlight lang="lua"> | |||
--Projects each element of a sequence to an Enumerable and flattens the resulting sequences into one sequence. | |||
---@param self Enumerable | |||
---@param other any | |||
---@param resultSelector? fun(left: any, right: any): any | |||
function Enumerable:zipBy(other, resultSelector) | |||
</syntaxhighlight> | |||
=== toDictionary === | |||
<syntaxhighlight lang="lua"> | |||
---@param self Enumerable | |||
---@param keySelector fun(item: any, index: any): any | |||
---@param valueSelector fun(item: any, index: any): any | |||
---@return table | |||
function Enumerable:toDictionary(keySelector, valueSelector) | |||
</syntaxhighlight> | |||
=== toTable === | |||
<syntaxhighlight lang="lua"> | |||
---@param self Enumerable | |||
---@return table | |||
function Enumerable:toTable() | |||
</syntaxhighlight> | |||
=== toHashSet === | |||
<syntaxhighlight lang="lua"> | |||
---@param self Enumerable | |||
---@return table | |||
function Enumerable:toHashSet() | |||
</syntaxhighlight> | |||
</onlyinclude> |
edits