diff options
author | Ronan Collobert <ronan@collobert.com> | 2015-05-23 19:14:50 +0300 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2015-05-23 19:14:50 +0300 |
commit | 97299ce206ce007a6d3ec4542617f91ae7f23ca5 (patch) | |
tree | be247733a970461ad9b1c3cc9a279071de02a4ae /lua-5.1-rc/test/fibfor.lua | |
parent | e7a987ad3e7c4c6161bb4952415ed65a4f575b1b (diff) |
added experimental support for lua 5.1 with reference counting
Diffstat (limited to 'lua-5.1-rc/test/fibfor.lua')
-rw-r--r-- | lua-5.1-rc/test/fibfor.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lua-5.1-rc/test/fibfor.lua b/lua-5.1-rc/test/fibfor.lua new file mode 100644 index 0000000..8bbba39 --- /dev/null +++ b/lua-5.1-rc/test/fibfor.lua @@ -0,0 +1,13 @@ +-- example of for with generator functions + +function generatefib (n) + return coroutine.wrap(function () + local a,b = 1, 1 + while a <= n do + coroutine.yield(a) + a, b = b, a+b + end + end) +end + +for i in generatefib(1000) do print(i) end |