lua-users home
lua-l archive

Re: Strange behavior with for loop

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2016年05月08日 21:05 GMT+02:00 Christophe Devalland
<christophe.devalland@gmail.com>:
> Ok, thanks for explanations. Is there a workaround ?
function loop(start,stop,step)
 return function()
 local old = start
 start = start+step
 if old<stop or math.abs(old-stop)<1e-14 then return old end
 end
end
for i in loop(-0.5,0.5,0.2) do
 print(i)
end

AltStyle によって変換されたページ (->オリジナル) /