表
a = { }
b = { x = 1, ["hello, "] = "world!" }
a.astring = "ni, hao!"
a[1] = 100
a["a table"] = b
function foo()
end
function bar()
end
a[foo] = bar
--分别穷举表a和b
for k, v in pairs(a) do
print(k, "=>",...
分类:
其他好文 时间:
2014-07-22 23:00:33
阅读次数:
261
函数环境
function foo()
print(g or "No g defined!")
end
foo()
setfenv(foo, { g = 100, print = print }) --设置foo的环境为表{ g=100, ...}
foo()
print(g or "No g defined!")
--No g defined!
--100
--No g defined!...
分类:
其他好文 时间:
2014-07-22 22:59:54
阅读次数:
338
函数闭包
function createCountdownTimer(second)
local ms=second * 1000;
local function countDown()
ms = ms - 1;
return ms;
end
return countDown;
end
timer1 = createCountdownTimer(1);
for...
分类:
其他好文 时间:
2014-07-22 22:59:53
阅读次数:
307
裸差分约束。//#pragma comment(linker,
"/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#includ...
分类:
其他好文 时间:
2014-05-02 13:13:29
阅读次数:
290
开源存储产品提供商RHEL(gluster,ceph)提供对象、块和文件三种存储;Ceph已成为OpenStack上最通用的存储之一;swift,作为对象存储,稳定性还是没啥问题。sina那边使用,对他的评价很高。淘宝选择了sheepdog通常而言,开源项目的来源有三:一是学校里的大牛作的课题,论文...
分类:
其他好文 时间:
2014-05-02 12:06:23
阅读次数:
293
1 #include 2 #include 3 #include 4 #define
INIT_STACK_SIZE 100 5 typedef struct 6 { 7 char * chOperator; 8 int dwtop; 9
}OPND;10 11 void I...
分类:
其他好文 时间:
2014-05-01 20:32:11
阅读次数:
366
启动SQL代理的时候报错如下:关调用实时(JIT)调试而不是此对话框的详细信息,请参见此消息的结尾。************** 异常文本
**************System.NullReferenceException: 未将对象引用设置到对象的实例。Server stack trace:
...
分类:
数据库 时间:
2014-05-01 20:21:21
阅读次数:
796
make linux在包含自 lua.h:16 的文件中,从
lua.c:15:luaconf.h:275:31: 错误:readline/readline.h:没有那个文件或目录luaconf.h:276:30:
错误:readline/history.h:没有那个文件或目录lua.c: In f...
分类:
其他好文 时间:
2014-05-01 18:57:43
阅读次数:
572
1. 调用其他的.lua文件 dofile("xx.lua");
2. 避免用 "_VERSION"这类的标识符,Lua将这类标识符用作特殊用途,通常保留"_"作为”哑变量“
3. Lua的一些保留字:
do in local nil until 等
4. 注释:-- 表示行注释 --[[ ... ]] 表示块注释
一般的块注释这样写:
--[[
...
分类:
其他好文 时间:
2014-04-30 22:34:38
阅读次数:
270
会PHP的人都知道PHP中的print_r/var_export函数,可以方便的用于打印数组或导出变量,Lua中没有提供,实际应用中却是很多时候需要类似的功能。
今天便封装了个简单函数,实现类似功能,用来打印/导出table:...
分类:
Web程序 时间:
2014-04-30 22:22:39
阅读次数:
392