Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,19 @@
|
|||
local s = {1, 2, 2, 3, 4, 4, 5}
|
||||
|
||||
-- There is no output as 'prev' is created anew each time
|
||||
-- around the loop and set implicitly to nil.
|
||||
for i = 1, #s do
|
||||
local curr = s[i]
|
||||
local prev
|
||||
if i > 1 and curr == prev then print(i) end
|
||||
prev = curr
|
||||
end
|
||||
|
||||
-- Now 'prev' is created only once and reassigned
|
||||
-- each time around the loop producing the desired output.
|
||||
local prev
|
||||
for i = 1, #s do
|
||||
local curr = s[i]
|
||||
if i > 1 and curr == prev then print(i) end
|
||||
prev = curr
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue