Repository navigation
FlatMap
Dennis Corvers edited this page Oct 23, 2026
·
2 revisions
Projects each source value to an iterable and flattens the projected iterables
into one Enumerable. flatMap is deferred.
flattened = source:flatMap(selector)| Parameter | Type | Description |
|---|---|---|
selector |
function(value, position) |
Returns a table iterable for the source value. Position is 1-based. |
A new Enumerable containing the values of each selected iterable in source
order.
selectMany is an alias of flatMap. Each selector result must be a table
supported by LuaQ's iterator setup.
local drops = LuaQ.from({
{ npc = "Abyssal demon", items = { "Abyssal whip", "Coins" } },
{ npc = "Gargoyle", items = { "Granite maul", "Coins" } },
})
:flatMap(function(dropTable) return dropTable.items end)
:toTable()
-- { "Abyssal whip", "Coins", "Granite maul", "Coins" }- 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