代码搜索:Lua
找到约 9,588 项符合「Lua」的源代码
代码结果 9,588
www.eeworm.com/read/398754/7925762
lua bisect.lua
-- bisection method for solving non-linear equations
delta=1e-6 -- tolerance
function bisect(f,a,b,fa,fb)
local c=(a+b)/2
io.write(n," c=",c," a=",a," b=",b,"\n")
if c==a or c==b or math.abs(a-b)
www.eeworm.com/read/398754/7925771
lua table.lua
-- make table, grouping all data for the same item
-- input is 2 columns (item, data)
local A
while 1 do
local l=io.read()
if l==nil then break end
local _,_,a,b=string.find(l,'"?([_%w]+)"?%s*(.*)
www.eeworm.com/read/398754/7925775
lua fib.lua
-- fibonacci function with cache
-- very inefficient fibonacci function
function fib(n)
N=N+1
if n
www.eeworm.com/read/398754/7925779
lua printf.lua
-- an implementation of printf
function printf(...)
io.write(string.format(...))
end
printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date())
www.eeworm.com/read/398754/7925789
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/398754/7925799
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/398754/7925802
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/398754/7925806
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/398754/7925810
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"))
assert(f:write(string.dump(assert(loadf
www.eeworm.com/read/398754/7925815
lua echo.lua
-- echo command line arguments
for i=0,table.getn(arg) do
print(i,arg[i])
end