代码搜索:Lua
找到约 9,588 项符合「Lua」的源代码
代码结果 9,588
www.eeworm.com/read/154878/11921308
lua fibfor.lua
-- example of for with generator functions
function generatefib (n)
return coroutine.wrap(function ()
local a,b = 1, 1
while a
www.eeworm.com/read/154878/11921316
lua globals.lua
-- reads luac listings and reports global variable usage
-- lines where a global is written to are marked with "*"
-- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua
while
www.eeworm.com/read/154878/11921317
lua env.lua
-- read environment variables as if they were global variables
local f=function (t,i) return os.getenv(i) end
setmetatable(getfenv(),{__index=f})
-- an example
print(a,USER,PATH)
www.eeworm.com/read/154878/11921319
lua life.lua
-- life.lua
-- original by Dave Bollinger posted to lua-l
-- modified to use ANSI terminal escape sequences
-- modified to use for instead of while
local write=io.write
A
www.eeworm.com/read/154878/11921320
lua luac.lua
-- bare-bones luac in Lua
-- usage: lua luac.lua file.lua
assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua")
f=assert(io.open("luac.out","wb"))
f:write(string.dump(assert(loadfile(arg
www.eeworm.com/read/154878/11921321
lua echo.lua
-- echo command line arguments
for i=0,table.getn(arg) do
print(i,arg[i])
end
www.eeworm.com/read/154878/11921322
lua sieve.lua
-- the sieve of of Eratosthenes programmed with coroutines
-- typical usage: lua -e N=1000 sieve.lua | column
-- generate all the numbers from 2 to n
function gen (n)
return coroutine.wrap(function
www.eeworm.com/read/154878/11921323
lua xd.lua
-- hex dump
-- usage: lua xd.lua < file
local offset=0
while 1 do
local s=io.read(16)
if s==nil then return end
io.write(string.format("%08X ",offset))
string.gsub(s,"(.)",function (c) io.write
www.eeworm.com/read/154878/11921324
lua cf.lua
-- temperature conversion table (celsius to farenheit)
for c0=-20,50-1,10 do
io.write("C ")
for c=c0,c0+10-1 do
io.write(string.format("%3.0f ",c))
end
io.write("\n")
io.write("F ")
for c=c
www.eeworm.com/read/154878/11921325
lua factorial.lua
-- function closures are powerful
-- traditional fixed-point operator from functional programming
Y = function (g)
local a = function (f) return f(f) end
return a(function (f)