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... 阅读全文
posted @ 2016-09-30 00:49 zzyoucan 阅读(512) 评论(0) 推荐(0) 编辑
摘要:#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... 阅读全文
posted @ 2016-09-28 00:09 zzyoucan 阅读(159) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2016-09-24 22:06 zzyoucan 阅读(128) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2016-09-24 00:33 zzyoucan 阅读(190) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2016-09-21 00:01 zzyoucan 阅读(220) 评论(0) 推荐(0) 编辑
摘要:--匿名函数使用upvalue i保存他的计数, 闭包是一个函数加上它可以正确访问的upvalues function newCounter() local i = 0 return function() i = i + 1 return i end end c1 = newCounter() print(c1()) print(c1()... 阅读全文
posted @ 2016-09-19 00:05 zzyoucan 阅读(134) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示