--泛型 for 的使用(lua)
2009-06-11 11:53
267 查看
--泛型 for 的使用
table_a={
{1,4,7};
{2,5,8};
{3,5,7};
{2,4,6};
{1,8};
{3,6};
{2,7};
{4,5};
};
function isSameItem(table_1,table_2)
for i,v in pairs(table_1) do
if table_2[i] ~= v then
return false;
end
end
return true;
end
a = {1,4,7};
b = {3,5,8};
function test(t)
local flag = false;
local index = 0;
for i,v in pairs(table_a) do
if(isSameItem(t,v)) then
flag = true;
index = i;
end
end
if not flag then
print("没找到");
else
print(index.."号");
end
end
test(a);
test(b);
table_a={
{1,4,7};
{2,5,8};
{3,5,7};
{2,4,6};
{1,8};
{3,6};
{2,7};
{4,5};
};
function isSameItem(table_1,table_2)
for i,v in pairs(table_1) do
if table_2[i] ~= v then
return false;
end
end
return true;
end
a = {1,4,7};
b = {3,5,8};
function test(t)
local flag = false;
local index = 0;
for i,v in pairs(table_a) do
if(isSameItem(t,v)) then
flag = true;
index = i;
end
end
if not flag then
print("没找到");
else
print(index.."号");
end
end
test(a);
test(b);
相关文章推荐
- 深入解读Lua中迭代器与泛型for的使用
- Lua学习笔记(七):迭代器与泛型for
- lua迭代器与泛型for
- Lua中的迭代器和泛型for实例
- Lua中的closure、泛型for
- Lua学习笔记-迭代器和泛型for
- Lua学习笔记 第七章 迭代器与泛型for
- Lua_第 7 章 迭代器与泛型 for
- Step By Step(Lua迭代器和泛型for)
- Lua For Windows环境配置及Editplus编辑工具使用
- Lua For windows 编辑器的使用
- Lua迭代器和泛型for)
- Step By Step(Lua迭代器和泛型for)
- Lua中for循环语句的使用教程
- LUA学习笔记--泛型for进行迭代处理的细节
- Lua_泛型for与迭代器
- lua 泛型for
- lua 泛型for
- Lua For Windows环境配置及Editplus编辑工具使用
- Lua For Windows的配置与SciTE的使用