S
Тот код который я показал
V
luajit c:/loader.lua c:/loadable.lua
^Я юзаю шорткаты notepad++, но можно вплавить loader в сишку, с минимальными изменениями, чтобы он запускал нужное тебе.
скрипт, который я хочу запустить loader'ом
Size: a a a
S
Тот код который я показал
V
luajit c:/loader.lua c:/loadable.lua
^Я юзаю шорткаты notepad++, но можно вплавить loader в сишку, с минимальными изменениями, чтобы он запускал нужное тебе.
скрипт, который я хочу запустить loader'ом
S
LO
S
D
🇮🇳 ࿗ ॐ Prathamesh Fad
deleted. Reason: external link (?)D
Oyedalu Spy
deleted. Reason: external link (?)KA
A
A
-- Closures and anonymous functions are ok:
function adder(x)
-- The returned function is created when adder is
-- called, and remembers the value of x:
return function (y) return x + y end
end
a1 = adder(9)
a2 = adder(36)
print(a1(16)) --> 25
print(a2(64)) --> 100
I
-- Closures and anonymous functions are ok:
function adder(x)
-- The returned function is created when adder is
-- called, and remembers the value of x:
return function (y) return x + y end
end
a1 = adder(9)
a2 = adder(36)
print(a1(16)) --> 25
print(a2(64)) --> 100
L
A
L
S
local func, err = loadstring("print(10)")
func()
> 10
A
S
-- Closures and anonymous functions are ok:
function adder(x)
-- The returned function is created when adder is
-- called, and remembers the value of x:
return function (y) return x + y end
end
a1 = adder(9)
a2 = adder(36)
print(a1(16)) --> 25
print(a2(64)) --> 100
function iter(tbl)
local i = #tbl + 1
return function()
i = i - 1
if not tbl[i] then return end
return i, tbl[i]
end
end
local t = {"a", "b", "c"}
for i, v in iter(t) do
print(i, v)
end
> 3 c
> 2 b
> 1 a
function collector()
local res = {}
return function(v)
if not v then return unpack(res) end
res[#res + 1] = v
end
end
local cl = collector()
cl(1)
cl(2)
cl(3)
a, b, c = cl()
print(a, b, c)
>1 2 3
AY
AY
S
function iter(tbl)
local i = #tbl + 1
return function()
i = i - 1
if not tbl[i] then return end
return i, tbl[i]
end
end
local t = {"a", "b", "c"}
for i, v in iter(t) do
print(i, v)
end
> 3 c
> 2 b
> 1 a
function collector()
local res = {}
return function(v)
if not v then return unpack(res) end
res[#res + 1] = v
end
end
local cl = collector()
cl(1)
cl(2)
cl(3)
a, b, c = cl()
print(a, b, c)
>1 2 3
-- осциллятор, пихаем общую частоту/частоту/амплитуду
local function osc(freq, ampl, rate)
local sin = math.sin
local tau = math.pi * 2
local freq = freq or 400
local ampl = ampl or 1
local rate = rate or 44100
local dt = 1/rate
local time = 0
return function(fr)
time = time + (fr or freq) * dt
return sin(tau * time) * ampl
end
end
local o = osc(400, 1, 44100) --> новый осциллятор
local samples = {}
for i = 1, 100 do
-- генерим синусоиду
samples[i] = o()
end
-- подаём samples на звуковуху ))