[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Popularity contest
- From: David Manura <dm.lua@...>
- Date: Mon, 26 Sep 2011 21:51:14 -0400
On Mon, Sep 26, 2011 at 1:05 PM, KR <krunal.rao78@gmail.com> wrote:
> local min, max, sin, cos = ridx(math, "min, max, sin, cos")
Warning, this is a hack:
local function from(t)
local j, k
for i=1, math.huge do
local name = debug.getlocal(2, i)
if not name then break end
if name == '_' then j = i end
k = i
end
assert(j, 'missing variable `_`')
for i=j+1, k do
local name = debug.getlocal(2, i)
debug.setlocal(2, i, t[name])
end
end
local _, lower, upper from(string)
local _, sqrt, abs from(math)
local x
assert(sqrt(4) == 2 and abs(-2) == 2)
assert(lower('Abc') == 'abc' and upper('Abc') == 'ABC')
assert(x == nil)
print 'DONE'