Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,37 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
-- Create a 4 dimensional list of the required size and
|
||||
-- initialize successive elements to the values 1 to 120.
|
||||
local m = 1
|
||||
local a4 = table.create(5)
|
||||
for i = 1, 5 do
|
||||
a4[i] = table.create(4)
|
||||
for j = 1, 4 do
|
||||
a4[i][j] = table.create(3)
|
||||
for k = 1, 3 do
|
||||
a4[i][j][k] = table.create(2)
|
||||
for l = 1, 2 do
|
||||
a4[i][j][k][l] = m
|
||||
m += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print($"First element = {a4[1][1][1][1]}") -- access and print value of first element
|
||||
a4[1][1][1][1] = 121 -- change value of first element
|
||||
print()
|
||||
|
||||
-- Access and print values of all elements in 12 x 10 tabular format.
|
||||
local c = 0
|
||||
for i = 1, 5 do
|
||||
for j = 1, 4 do
|
||||
for k = 1, 3 do
|
||||
for l = 1, 2 do
|
||||
fmt.write("%4d", a4[i][j][k][l])
|
||||
c += 1
|
||||
if c % 10 == 0 then print() end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue