Anonymous

Module:FunList/EnumerableExtensions: Difference between revisions

From Melvor Idle
no edit summary
(Created page with "local Enumerable = require('Module:Enumerable') local Iterators = require('Module:Iterators') -- Helper function to check if objects are equal. local function isEqual(obj1, obj2) local type1 = type(obj1) local type2 = type(obj2) if type1 ~= type2 then return false end if type1 == "number" or type1 == "string" or type1 == "boolean" then return obj1 == obj2 elseif type1 == "table" then if #obj1 ~= #obj2 then retur...")
 
No edit summary
Line 1: Line 1:
local Enumerable = require('Module:Enumerable')
local Enumerable = require('Enumerable')
local Iterators = require('Module:Iterators')
local Iterators = require('Iterators')


-- Helper function to check if objects are equal.
-- Helper function to check if objects are equal.
Line 207: Line 207:
end
end


-- Returns the sum value of a sequence of values.
function Enumerable:sum()
function Enumerable:sum()
local total = 0
local total = 0
Line 248: Line 249:
end
end


--Groups the elements of a sequence.
---@param self Enumerable
---@param self Enumerable
---@param keySelector fun(param: any): any
---@param keySelector fun(param: any): any
Line 255: Line 257:
end
end


--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 self Enumerable
---@param keySelector fun(param: any): any
---@param keySelector fun(param: any): any
Line 263: Line 266:
end
end


--Produces the set intersection of two sequences.
---@param self Enumerable
---@param self Enumerable
---@param other Enumerable
---@param other Enumerable
Line 269: Line 273:
end
end


--Produces the set intersection of two sequences according to a specified key selector function.
---@param self Enumerable
---@param self Enumerable
---@param other Enumerable
---@param other Enumerable
Line 276: Line 281:
end
end


--Projects each element of a sequence into a new form.
---@param self Enumerable
---@param self Enumerable
---@param selector fun(value: any, index: any): any
---@param selector fun(value: any, index: any): any
Line 282: Line 288:
end
end


--Sorts a sequence.
---@param self Enumerable
---@param self Enumerable
---@return SortableIterator
---@return SortableIterator
Line 288: Line 295:
end
end


--Sorts a sequence in descending order.
---@param self Enumerable
---@param self Enumerable
---@return SortableIterator
---@return SortableIterator
Line 294: Line 302:
end
end


--Sorts a sequence based on a specified key selector function.
---@param self Enumerable
---@param self Enumerable
---@return SortableIterator
---@return SortableIterator
Line 300: Line 309:
end
end


--Sorts a sequence based on a specified key selector function in descending order.
---@param self Enumerable
---@param self Enumerable
---@return SortableIterator
---@return SortableIterator
Line 306: Line 316:
end
end


--Sorts a sorted sequence further based on a specified key selector function.
---@param self SortableIterator
---@param self SortableIterator
---@return SortableIterator
---@return SortableIterator
Line 313: Line 324:
end
end


--Sorts a sorted sequence further based on a specified key selector function in descending order.
---@param self SortableIterator
---@param self SortableIterator
---@return SortableIterator
---@return SortableIterator
Line 320: Line 332:
end
end


--Produces the set union of two sequences according to a specified key selector function.
---@param self Enumerable
---@param self Enumerable
---@param other any
---@param other any
Line 326: Line 339:
end
end


--Produces the set union of two sequences according to a specified key selector function.
---@param self Enumerable
---@param self Enumerable
---@param other any
---@param other any
Line 333: Line 347:
end
end


--Returns unique (distinct) elements from a sequence according to a specified key selector function.
---@param self Enumerable
---@param self Enumerable
function Enumerable:unique()
function Enumerable:unique()
Line 338: Line 353:
end
end


--Returns unique (distinct) elements from a sequence according to a specified key selector function.
---@param self Enumerable
---@param self Enumerable
---@param keySelector? fun(value: any, index: any): any
---@param keySelector? fun(value: any, index: any): any
Line 344: Line 360:
end
end


--Filters a sequence of values based on a predicate.
---@param self Enumerable
---@param self Enumerable
---@param predicate fun(value: any, index: any): boolean
---@param predicate fun(value: any, index: any): boolean
Line 350: Line 367:
end
end


--Projects each element of a sequence to an Enumerable and flattens the resulting sequences into one sequence.
---@param self Enumerable
---@param self Enumerable
---@param other any
---@param other any
Line 356: Line 374:
end
end


--Projects each element of a sequence to an Enumerable and flattens the resulting sequences into one sequence.
---@param self Enumerable
---@param self Enumerable
---@param other any
---@param other any
2,875

edits