Hello all,
Let's get to the point right away. =) Right now I am looping through a string with `for word in str:gmatch("%w+") do`.
Is there any way in which I can write a subloop that will take `word` and all that remains, and then continues to take words away?
For example, I have the string 'a b c'. Now I process 'a' in my outer-loop, and inner-loop should go ['a b c', 'a b', 'a']. Next 'b' goes ['b c', 'b']. Last comes 'c', which goes ['c'].
I can personally only think of an ugly way to do this with two while loops, but I have the feeling it could be done in a neater fashion. Is there anyone here willing to point me in the right direction?
Let's get to the point right away. =) Right now I am looping through a string with `for word in str:gmatch("%w+") do`.
Is there any way in which I can write a subloop that will take `word` and all that remains, and then continues to take words away?
For example, I have the string 'a b c'. Now I process 'a' in my outer-loop, and inner-loop should go ['a b c', 'a b', 'a']. Next 'b' goes ['b c', 'b']. Last comes 'c', which goes ['c'].
I can personally only think of an ugly way to do this with two while loops, but I have the feeling it could be done in a neater fashion. Is there anyone here willing to point me in the right direction?