demo.lua 345 字节
Newer Older
Y
yihaoDeng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
funcName = "test"

global =  {} 
global["sum"] = 0.0
global["num"] = 0

function test_init()
  return global  
end

function test_add(rows, ans)
  for i=1, #rows do
    ans["sum"] = ans["sum"] + rows[i] * rows[i]  
  end
  ans["num"] = ans["num"] + #rows  
  return ans; 
end

function test_finalize(ans) 
  return ans["sum"]/ans["num"]; 
end