09 2016 档案
摘要://顶 -1 -2 -3 //顶 3 2 1 #include #include extern "C"{ #include #include #include } #pragma comment(lib,"lua.lib") void stackDump(lua_State* L) { int i; int top = lua_gett...
阅读全文
摘要:#include #include extern "C"{ #include #include #include } #pragma comment(lib,"lua.lib") int main() { char buff[256]; int error; lua_State* L = luaL_newstate(); lua...
阅读全文
摘要:Window = {} Window.prototype = {x = 0, y = 0, width = 70, height = 100} Window.mt = {} function Window.new(o) setmetatable(o, Window.mt) return o end --[[Window.mt.__index = function (table...
阅读全文
摘要:Set = {} Set.mt = {} function Set.new(t) local set = {} setmetatable(set, Set.mt) for _, l in ipairs(t) do set[l] = true end return set end function Set.union(a, b) local res = S...
阅读全文
摘要:function list_iter(t) local i = 0 local n = table.getn(t) return function() i = i + 1 if i <= n then return t[i] end end end t = {10, 20, 30} iter = list_iter(t) whil...
阅读全文
摘要:--匿名函数使用upvalue i保存他的计数, 闭包是一个函数加上它可以正确访问的upvalues function newCounter() local i = 0 return function() i = i + 1 return i end end c1 = newCounter() print(c1()) print(c1()...
阅读全文