Init
This commit is contained in:
commit
c0b5de5a4f
5 changed files with 161 additions and 0 deletions
28
adjmat.lua
Normal file
28
adjmat.lua
Normal 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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue