摘要: 泛型for----->第一遍 10 20 30 40 50 泛型for----->第二遍 [root@localhost for]# cat for1.lua function iter( t ) local i = 0 return function() i = i + 1 return t[i]... 阅读全文
posted @ 2018-06-28 11:44 ghostwu 阅读(244) 评论(0) 推荐(0) 编辑
摘要: -- return the index of max number and himself -- 函数可以返回多个值 function get_max( T ) local index = 1 local max = T[1] for i, v in ipairs( T ) do if v > max then ... 阅读全文
posted @ 2018-06-28 10:06 ghostwu 阅读(607) 评论(0) 推荐(0) 编辑
摘要: function add( a, b ) return a + b end -- print( add( 10, 20 ) ) function loopT( T ) for i, v in ipairs( T ) do print( i, v ) end end -- loopT{ 10, 20, 30,... 阅读全文
posted @ 2018-06-28 09:12 ghostwu 阅读(629) 评论(0) 推荐(0) 编辑
Copyright ©2017 ghostwu