Re: Dynamic foreach algorithm
- From: "H. S. Lahman" <hsl@xxxxxxxxxxxxxxxxx>
- Date: Tue, 22 Jan 2008 19:26:19 GMT
Responding to Daniel T...
foreach(level1 = 0; level1 < somecount; level++) {First note that the bodies of these two examples are necessarily different because they are parameterized differently (i.e., the second example needs level3 but the first does not).
foreach(level2 = 0; level2 < somecount2; level2++) {
// do something with level1 and level2
}
}
If you knew in advance that you three such levels you would do this
foreach(level1 = 0; level1 < somecount; level++) {
foreach(level2 = 0; level2 < somecount2; level2++) {
foreach(level3 = 0; level3 < somecount3; level3++) {
// do something using level1, level2, level3
}
}
}
We really don't know that for sure. The bodies of the loops in the two examples may very well not *need* the extra variable. That's why I asked early on what they looked like.
I was taking his code comments at face value.
--
There is nothing wrong with me that could
not be cured by a capful of Drano.
H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH
.
- Follow-Ups:
- Re: Dynamic foreach algorithm
- From: Daniel T.
- Re: Dynamic foreach algorithm
- References:
- Dynamic foreach algorithm
- From: Veloz
- Re: Dynamic foreach algorithm
- From: H. S. Lahman
- Re: Dynamic foreach algorithm
- From: Daniel T.
- Dynamic foreach algorithm
- Prev by Date: Re: Place objects in threads and processes in UML
- Next by Date: Re: Place objects in threads and processes in UML
- Previous by thread: Re: Dynamic foreach algorithm
- Next by thread: Re: Dynamic foreach algorithm
- Index(es):