Subscribed unsubscribe Subscribe Subscribe

TI-Nspire & Lua / スクリプティングのヒント / pairs() も使わない

Reference: http://adriweb.free.fr/t3/2014/Advanced_TI-Nspire_Lua_Programming.pptx, p.8

local list = {}
for i = 1, 8000000 do
   list[i] = i
end


-- 1
timeStart = timer.getMilliSecCounter()
for i = 1, #list do
   local value = list[i]
end
print("1: takes"..timer.getMilliSecCounter() - timeStart.." msec")

-- 2
timeStart = timer.getMilliSecCounter()
for _, v in pairs(list) do
   local value = v
end
print("2: takes"..timer.getMilliSecCounter() - timeStart.." msec")

f:id:ti-nspire:20170203090632p:plain

Remove all ads