Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Identity-matrix/Lua/identity-matrix.lua
Normal file
18
Task/Identity-matrix/Lua/identity-matrix.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function identity_matrix (size)
|
||||
local m = {}
|
||||
for i = 1, size do
|
||||
m[i] = {}
|
||||
for j = 1, size do
|
||||
m[i][j] = i == j and 1 or 0
|
||||
end
|
||||
end
|
||||
return m
|
||||
end
|
||||
|
||||
function print_matrix (m)
|
||||
for i = 1, #m do
|
||||
print(table.concat(m[i], " "))
|
||||
end
|
||||
end
|
||||
|
||||
print_matrix(identity_matrix(5))
|
||||
Loading…
Add table
Add a link
Reference in a new issue