多重赋值
1)函数是最后一个表达式,则保留函数所有的返回值
2)函数没有返回值或者没有足够多的返回值,则nil补充
3)如果函数不是最后一个表达式,则只保留的第一个返回值返回值
函数调用时,使用圆括号,则只返回一个值
closure:
可以将已有的api重新定义,并进行增强
tail recursion:
一个函数调用是另一个函数的最后一个动作,如下fib函数,
function fib(n, r, c)
if n == 0 then
return c
else
return fib(n-1, r+c, r);
end
end
print(fib2(10, 1, 0));