
Lua学习笔记
Fenice
狂奔的蜗牛
展开
-
lua basic
注释 --[[ --]]解除注释 ---[[ --]]赋值 a ,b = 10, 2*x交换 x, y = y, xa, b, c = 0, 1print(a,b,c) -->0 1 nila, b, c = 0print(a,b,c) -原创 2014-02-12 20:32:06 · 1632 阅读 · 0 评论 -
lua coroutine filter
function send (x) coroutine.yield(x)endfunction producer () return coroutine.create (function () while true do local x = io.read() send(x) end end)endfunction receive (prod) local原创 2014-02-13 00:11:06 · 1303 阅读 · 0 评论 -
lua advanced function
接受函数作为参数的函数成为”高阶函数“network = { {name= "gramma", IP = "210.26.30.34"}, {name= "arrial", IP = "210.26.30.35"}, {name= "lua", IP = "210.26.30.36"}, {name= "cplus", IP = "210原创 2014-02-12 20:33:16 · 1190 阅读 · 0 评论 -
lua function
dofile 'xx.lua' 加载程序库function f(a, b) retrun a or b endf(3) a = 3, b = nil f(3, 4) a = 3, b = 4f(3, 4, 5) a = 3, b = 4多重返回值s, e = stirng.find("hello", " he")原创 2014-02-12 20:32:40 · 1362 阅读 · 0 评论 -
lua data structure
数组 a = {} for i = 1, 1000 do a[i] = 0 end print(#a) -->1000 a = {} for i = -5, 5 do a[i] = 0 end原创 2014-02-13 16:09:09 · 1202 阅读 · 0 评论 -
lua math库
atan2、sinh、cosh、tanh这4个应该用不到。函数名描述示例结果pi圆周率math.pi3.1415926535898abs取绝对值math.abs(-2012)2012ceil向上取整math.ceil(9.1)1原创 2014-03-16 23:59:48 · 1504 阅读 · 0 评论