-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex16.2.lua
39 lines (38 loc) · 843 Bytes
/
ex16.2.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local function multiload(...)
local t = {...}
local n = #t
local last = nil
local i = 1
return load(function ()
if last then
local res = last()
if not res then
last = nil
else
return res
end
end
local current = t[i]
repeat
if type(current) == "string" then
i = i + 1
return current
elseif type(current) == "function" then
i = i + 1
last = current
local ret = last()
if ret then
return ret
end
else
i = i + 1
end
until i > n
end)
-- for i in pairs{...} do
-- print(i)
-- end
end
local file = assert(io.open("test.txt", "r"))
local f = multiload("print(", file:lines(), ")")
f()