Difference between revisions of "User:Hajo/test2"
Jump to navigation
Jump to search
m (→Prog1: string.format()) |
|||
Line 1: | Line 1: | ||
==Table-test2== | ==Table-test2== | ||
− | + | x,y,z | |
===Lua - Online-IDEs=== | ===Lua - Online-IDEs=== | ||
Line 10: | Line 10: | ||
====Prog1==== | ====Prog1==== | ||
+ | http://ideone.com/1fhw6j | ||
+ | |||
<source lang="lua"> | <source lang="lua"> | ||
+ | -- table x,y,z | ||
n=1 | n=1 | ||
y=0 | y=0 | ||
Line 16: | Line 19: | ||
for z = -n, n do | for z = -n, n do | ||
--print(x,y,z) | --print(x,y,z) | ||
− | print( string.format("% | + | print( string.format("%3d %2d %2d", x,y,z) ) |
end | end | ||
end | end | ||
Line 22: | Line 25: | ||
=====Output===== | =====Output===== | ||
+ | -1 0 -1 | ||
+ | -1 0 0 | ||
+ | -1 0 1 | ||
+ | 0 0 -1 | ||
+ | 0 0 0 | ||
+ | 0 0 1 | ||
+ | 1 0 -1 | ||
+ | 1 0 0 | ||
+ | 1 0 1 | ||
+ | |||
+ | ====Prog2==== | ||
... | ... |
Revision as of 05:34, 11 March 2017
Table-test2
x,y,z
Lua - Online-IDEs
Example - Formatting a table:
Prog1
-- table x,y,z
n=1
y=0
for x = -n, n do
for z = -n, n do
--print(x,y,z)
print( string.format("%3d %2d %2d", x,y,z) )
end
end
Output
-1 0 -1 -1 0 0 -1 0 1 0 0 -1 0 0 0 0 0 1 1 0 -1 1 0 0 1 0 1
Prog2
...