标签:递归 int 语句 style element 结构 str ted 函数
function values(t) local i = 0 return function() i = i + 1 return t[i] end end t = {10, 20, 30} for element in values(t) do print(element) end local iterator function allwords() local state = {line = io.read(), pos = 1} return iterator, state end function iterator(state) while state.line do local s, e = string.find(state.line, "%w+", state,pos) if s then state.pos = e + 1 return string.sub(state.line, s, e) else state.line = io.read() state.pos = 1 end end return nil end
标签:递归 int 语句 style element 结构 str ted 函数
原文地址:http://www.cnblogs.com/sxhlinux/p/6127682.html