Module:FunList/Sandbox/doc
< Module:FunList | Sandbox
This is the documentation page for Module:FunList/Sandbox
Functions
new
---@param nextFunc fun(context: any, index: any):any, any
---@param index any
---@param contextFactory fun(): any
---@return Enumerator3
function Enumerator3.new(nextFunc, index, contextFactory)
create
---@param obj any
---@return Enumerator3
function Enumerator3.create(obj)
ipairs
---@return fun():table
function Enumerator3:ipairs()
where
---Filters a sequence of values based on a predicate.
---@param predicate fun(item: any, index: any): boolean
---@return Enumerator3
function Enumerator3:where(predicate)
map
---Projects each element of a sequence into a new form.
---@param selector fun(item: any, position: integer): any
---@return Enumerator3
function Enumerator3:map(selector)
flatMap
---Projects each element of a sequence and flattens the resulting sequences into one sequence.
---@param selector fun(item: any, position: integer): table
---@return Enumerator3
function Enumerator3:flatMap(selector)
concat
---Concatenates two sequences.
---@param second table
---@return Enumerator3
function Enumerator3:concat(second)
append
---Appends a value to the end of the sequence.
---@param item any
---@param index? any
---@return Enumerator3
function Enumerator3:append(item, index)
prepend
---Prepends a value to the start of the sequence.
---@param item any
---@param index? any
---@return Enumerator3
function Enumerator3:prepend(item, index)
unique
---Returns unique (distinct) elements from a sequence according to a specified key selector function.
---@param keySelector? fun(current: any, index: any): any
---@return Enumerator3
function Enumerator3:unique(keySelector)
difference
---Produces the set difference of two sequences according to a specified key selector function.
---@param second table
---@param keySelector? fun(current: any, index: any): any
---@return Enumerator3
function Enumerator3:difference(second, keySelector)
union
---Produces the set union of two sequences according to a specified key selector function.
---@param second table
---@param keySelector? fun(current: any, index: any): any
---@return Enumerator3
function Enumerator3:union(second, keySelector)
intersect
---Produces the set intersection of two sequences according to a specified key selector function.
---@param second table
---@param keySelector? fun(current: any, index: any): any
function Enumerator3:intersect(second, keySelector)
zip
---Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.
---@param second table
---@param resultSelector? fun(itema: any, itemb: any): any
---@return Enumerator3
function Enumerator3:zip(second, resultSelector)
groupBy
---Groups the elements of a sequence.
---@param keySelector fun(param: any): any
---@param elementSelector? fun(param: any): any
---@return Enumerator3
function Enumerator3:groupBy(keySelector, elementSelector)
groupByResult
---Groups the elements of a sequence.
---@param keySelector fun(param: any): any
---@param elementSelector? fun(param: any): any
---@param resultSelector fun(key: any, elements: any): any
---@return Enumerator3
function Enumerator3:groupByResult(keySelector, elementSelector, resultSelector)
sort
---Boilerplate function to setup various sorting Enumerator3
---@param self Enumerator3
---@param isDecending boolean
---@param selector? fun(current: any): any
---@return Enumerator3
local function getSorter(self, isDecending, selector)
sortDescending
function Enumerator3:sortDescending()
sortBy
function Enumerator3:sortBy(selector)
sortByDescending
function Enumerator3:sortByDescending(selector)
thenBy
function Enumerator3:thenBy(selector)
thenByDecending
function Enumerator3:thenByDecending(selector)
indexOf
---Determines the index of the first occurrence of a specified item.
---@param self Enumerator3
---@param item any
---@param comparer? fun(a: any, b: any): boolean
---@return integer
function Enumerator3.indexOf(self, item, comparer)
contains
---Determines whether the sequence contains the provided item according to an equality comparer.
---@param self table
---@param item any
---@param comparer? fun(a: any, b: any): boolean
---@return boolean
function Enumerator3.contains(self, item, comparer)
sequenceEquals
---Determines whether two sequences are equal according to an equality comparer.
---@param self table
---@param other table
---@param comparer? fun(a: any, b: any): boolean
---@return boolean
function Enumerator3.sequenceEquals(self, other, comparer)
firstOrDefault
---Returns the first item in the sequence, or a default value if there are no items in the sequence.
---@param self table
---@param predicate? fun(value: any, key: any): boolean
---@param defaultValue? any
---@return any
function Enumerator3.firstOrDefault(self, predicate, defaultValue)
first
---Returns the first item in the sequence, or an error if there are no items in the sequence.
---@param self table
---@param predicate? fun(value: any, key: any): boolean
---@return any
function Enumerator3:first(predicate)
lastOrDefault
---Returns the last item in the sequence, or a default value if there are no items in the sequence.
---@param self table
---@param predicate? fun(value: any, key: any): boolean
---@param defaultValue? any
---@return any
function Enumerator3:lastOrDefault(predicate, defaultValue)
last
---Returns the last item in the sequence, or an error if there are no items in the sequence.
---@param self table
---@param predicate? fun(value: any, key: any): boolean
---@return any
function Enumerator3:last(predicate)
count
---Returns the length of this collection.
---@param self table
---@return integer
function Enumerator3:count()
countBy
---Returns the number of elements in a sequence that match a predicate.
---@param self Enumerator3
---@param predicate fun(value: any, key: any): any
---@return integer
function Enumerator3:countBy(predicate)
all
---Determines whether all elements of a sequence satisfy a condition.
---@param self Enumerator3
---@param predicate fun(current: any, index: any): boolean
---@return boolean
function Enumerator3:all(predicate)
any
---Determines whether any element of a sequence exists or satisfies a condition.
---@param self Enumerator3
---@param predicate? fun(current: any, index: any): boolean
---@return boolean
function Enumerator3:any(predicate)
foreach
---Iterates over the sequence, applying a specified function to each element.
---@param self Enumerator3
---@param func fun(current: any): any
---@return nil
function Enumerator3:foreach(func)
aggregate
---Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
---@param self table
---@param func fun(accumulate: any, next: any): any
---@param seed? any
---@param resultSelector? fun(result: any): any
---@return any
function Enumerator3:aggregate(func, seed, resultSelector)
max
---Returns the maximum value in a sequence of values.
---@param self Enumerator3
---@return number
function Enumerator3:max()
maxBy
---Returns the item with the highest value in a sequence.
---@param self Enumerator3
---@param selector fun(item: any, index: any): number
---@return unknown
function Enumerator3:maxBy(selector)
min
---Returns the minimum value in a sequence of values.
---@param self Enumerator3
---@return number
function Enumerator3:min()
minBy
---Returns the item with the lowest value in a sequence.
---@param self Enumerator3
---@param selector fun(item: any, index: any): number
---@return unknown
function Enumerator3:minBy(selector)
sum
---Returns the sum value of a sequence of values.
---@param self Enumerator3
---@return number
function Enumerator3:sum()
toSet
---Creates a set from a table|Enumerator3 with a specified key for uniqueness.
---@param self table
---@param keySelector? fun(current: any, index: any): any
---@return table
function Enumerator3:toSet(keySelector)
toTable
---Creates an array from a table|Enumerator3
---@param self table
---@return table
function Enumerator3:toTable()
toLookup
---Creates a lookup from a table|Enumerator3
---This is a { key, { elements } } structure
---@param self table
---@param keySelector fun(value: any, index: any): any
---@param elementSelector? fun(value: any, index: any): any
---@return table
function Enumerator3:toLookup(keySelector, elementSelector)
toDictionary
---Creates a dictionary (key, value) structure based on a keyselector and an elementselector
---@param self Enumerator3
---@param keySelector? fun(value: any, key: any): any
---@param elementSelector? fun(value: any, key: any): any
---@return table
function Enumerator3:toDictionary(keySelector, elementSelector)
deepCopy
---Creates a deep copy of the provided object.
---@param self any
---@return any
function Enumerator3:deepCopy()
Function aliases
These aliases behave the same as the functions listed above. They only have a different name.
select
Alias for Enumerator3.map
selectMany
Alias for Enumerator3.flatMap
distinct
Alias for Enumerator3.unique
except
Alias for Enumerator3.difference
order
Alias for Enumerator3.sort
orderDecending
Alias for Enumerator3.sortDescending
orderBy
Alias for Enumerator3.sortBy
orderByDecending
Alias for Enumerator3.sortByDescending
each
Alias for Enumerator3.foreach
for_each
Alias for Enumerator3.foreach
length
Alias for Enumerator3.count
lengthBy
Alias for Enumerator3.countBy
has
Alias for Enumerator3.contains
fold
Alias for Enumerator3.aggregate
reduce
Alias for Enumerator3.aggregate