Sha256: 34735e769e6dd4f7d2880b9ca4004e8a4fbeba6209e41f3c46141f857830b244

Contents?: true

Size: 254 Bytes

Versions: 23

Compression:

Stored size: 254 Bytes

Contents

-- 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

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
dub-0.6.0 test/fixtures/app/vendor/lua/test/fibfor.lua
dub-0.5.1 test/fixtures/app/vendor/lua/test/fibfor.lua
dub-0.5.0 test/fixtures/app/vendor/lua/test/fibfor.lua