Repository navigation
Aggregate
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Reduces all values to one result using an accumulator function.
result = values:aggregate(func, seed, resultSelector)| Parameter | Type | Description |
|---|---|---|
func |
function(accumulator, value) |
Produces the next accumulator value. |
seed |
any (optional) | Initial accumulator. If omitted or nil, the first source value is used. |
resultSelector |
function(result) (optional) |
Transforms the final accumulator. |
The final accumulator, optionally transformed by resultSelector.
An empty source without a seed raises an error. fold and reduce are aliases
of aggregate.
local totalCoins = LuaQ.from({
{ player = "Ada", coins = 120 },
{ player = "Bryn", coins = 85 },
})
:aggregate(function(total, entry)
return total + entry.coins
end, 0)
-- 205- Home
- Getting Started
-
Functions
- aggregate
- all
- any
- concat
- contains
- count
- create
- createFrom
- deepCopy
- difference
- elementAt
- elementAtOrDefault
- first
- firstOrDefault
- flatMap
- foreach
- groupBy
- groupByResult
- indexOf
- intersect
- ipairs
- last
- lastOrDefault
- map
- max
- min
- pairs
- sequenceEquals
- single
- singleOrDefault
- sort
- sortBy
- sortByDescending
- sortDescending
- sum
- take
- takeWhile
- thenBy
- thenByDecending
- toLookup
- toMap
- toSet
- toTable
- union
- unique
- where
- zip
- Aliases