http://d.puremagic.com/issues/show_bug.cgi?id=8155
--- Comment #2 from [email protected] 2012-06-05 13:45:11 PDT --- (In reply to comment #1) > Sorry, but I *do* use the index variable: I didn't said that index variable is never useful and never used. I have said its need is rare, in my experience of using Python and in my experience of looking at Haskell code. On the other hand I have shown and offered 3 different ways to solve the problem without lockstep. lockstep is redundant, and its usage doesn't shorten a significant amount of code: there are redundant operations that are way more commonly useful than lockstep, like amap/afilter. > https://github.com/AndrejMitrovic/DWinProgramming/blob/master/Samples/Chap06/KeyView1/KeyView1.d#L198 > https://github.com/AndrejMitrovic/DWinProgramming/blob/master/Samples/Chap09/BtnLook/BtnLook.d#L144 Of the 3 alternative solution, using enumerate, those: foreach (index, button, ref hwndButton; lockstep(buttons, hwndButtons)) foreach (index, myMsg; lockstep(iota(0, min(cLines, cyClient / cyChar - 1)), retro(msgArr))) Become: foreach (index, button, ref hwndButton; enumerate(zip(buttons, hwndButtons))) foreach (index, myMsg; enumerate(zip(iota(min(cLines, cyClient / cyChar - 1)), retro(msgArr)))) Or maybe: foreach (index, button, ref hwndButton; buttons.zip(hwndButtons).enumerate()) foreach (index, myMsg; min(cLines, cyClient / cyChar - 1).iota().zip(msgArr.retro()).enumerate()) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
