On 30 Aug 2008, at 19:59, Arnaud Delobelle wrote:
On 30 Aug 2008, at 19:32, Bruce Leban wrote:
On Sat, Aug 30, 2008 at 10:56 AM, Arnaud Delobelle
wrote:
Finally, my function works gracefully with nested loops:
for i, i_last in flaglast(items): for j, j_last in flaglast(jtems): ...
without the need for a 'named loop', about which I feel very circumspect.
Unfortunately, your function has to get the N+1st item before the body processes the Nth element so if getting the elements has side effects and the body might break, then this changes the behavior of the loop. With an explicit call to an <is this the last> function, we know exactly when it will peek ahead in the list.
--- Bruce
How do you propose to find out if the item is the last without getting the next one?
-- Arnaud
Sorry I hadn't read your reply closely enough. I agree, but I was only reproducing the functionality of some code in the thread without the need for new syntax. -- Arnaud