function getMin(a)
local min_i = -1
local min_v = math.huge
for i, v in pairs(a) do
if min_v > v then
min_v = v
min_i = i
end
end
return min_i, min_v
end
local heights = {167, 195, 180, 153, 155}
local minHeight_i, minHeight = getMin(heights)
print("a[" .. minHeight_i .. "] = " .. minHeight)
키워드 : function
Thursday, May 3, 2012
Multiple results 를 return 하는 함수 구현
Labels:
Lua
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment