Home - FireDragon91245/Lua-Linq GitHub Wiki
Lua-Linq
Lua-Linq gives you three main building blocks:
linq.list(...)for ordered valueslinq.dict(...)for key/value dataenumerablepipelines for filtering, projecting, aggregating, and iterating
The library is built around small chainable methods like where, select, collect, first, last, max, and min.
Quick start
- Use
linq.list(...)when order matters. - Use
linq.dict(...)when keys matter. - Call
:enumerate()or:iter()when you need lower-level control.
Example: list pipeline
local linq = require("linq")
local names = linq.list(
{ name = "iron plate", count = 120 },
{ name = "copper cable", count = 450 },
{ name = "steel plate", count = 40 }
)
:where("item => item.count >= 100")
:select("item => item.name")
:tolist()
for name in names:iter() do
print(name)
end
Example: manual iterator control
local linq = require("linq")
local next_item = linq.list(5, 10, 15, 20)
:where("n => n >= 10")
:iter()
print(next_item()) -- 10
print(next_item()) -- 15
print(next_item()) -- 20
print(next_item()) -- nil
Example: key/value iteration
local linq = require("linq")
local recipes = linq.dict({
iron = { amount = 30 },
copper = { amount = 45 },
steel = { amount = 12 }
})
for key, value in recipes:iter() do
print(key, value.amount)
end
Where to go next
- Start with the Enumerable section for the shared pipeline methods.
- Use the List section for list-specific helpers like
add,copy, andenumerate. - Use the Dict section for dict-specific helpers like
keys,values, and key/value iteration.