how to do gen for loop starting at a given point?
-
- Prole
- Posts: 16
- Joined: Wed Feb 05, 2014 11:31 pm
- Location: Ohio USA
how to do gen for loop starting at a given point?
If I am looping through i,v in pairs in a table and want to compare v to all the remaining v s how do I write a sub loop that begins with the next item in the table and goes to the end?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: how to do gen for loop starting at a given point?
Do you mean pairs or ipairs? If the latter:
Code: Select all
for i, v in ipairs(t) do
for j = i + 1, #t do
-- do your thing with i, v, j and t[j]
end
end
Help us help you: attach a .love.
-
- Prole
- Posts: 16
- Joined: Wed Feb 05, 2014 11:31 pm
- Location: Ohio USA
Re: how to do gen for loop starting at a given point?
I could make it ipairs. Thanks Robin
Who is online
Users browsing this forum: No registered users and 4 guests