[ create a new paste ] login | about

Link: http://codepad.org/TcmF9Xnk    [ raw code | output | fork ]

Lua, pasted on Jan 4:
function t_add(a,b)
local len_a = #a
local len_b = #b
lcoal temp ={}
local max = len_a > len_b and len_a or len_b
print(max)
for i=1,max do
if a[i] == nil or b[i] == nil then
break
end
print(a[i]+b[i])
temp[i] = a[i]+b[i]
end
return temp
end
local t = {__add = t_add}
local t1 = {1,2,3,4,5}
local t2 = {6,7,8,9,10,11}
setmetatable(t1, t)
setmetatable(t2, t)
print(getmetatable(t)==t2)
c = t1+t2
fro i,v in ipairs(c) do
print(i,v)
end


Output:
1
line 4: '=' expected near 'temp'


Create a new paste based on this one


Comments: