This commit is contained in:
Imbus 2025-08-27 19:44:15 +02:00
commit c0b5de5a4f
5 changed files with 161 additions and 0 deletions

28
adjmat.lua Normal file
View file

@ -0,0 +1,28 @@
local N = 4
-- 0 means no edge
local adjMatrix = {
{ 0, 5, 3, 0 }, -- edges from vertex 0
{ 0, 0, 0, 2 }, -- edges from vertex 1
{ 0, 0, 0, 7 }, -- edges from vertex 2
{ 0, 0, 0, 0 }, -- edges from vertex 3
}
for i = 1, N do
for j = 1, N do
io.write(adjMatrix[i][j], " ")
end
print()
end
local function foreach(list, fn)
for _, v in ipairs(list) do
fn(v)
end
end
local numbers = { 10, 20, 30 }
foreach(numbers, print)
print("Hello")