Talk:Loops/With multiple ranges: Difference between revisions

→‎Further explanation needed: added some comments and explanation of what was being thought of at the time of task creation and task requirements..
(→‎other DO loop cases: Loops/Wrong ranges created)
(→‎Further explanation needed: added some comments and explanation of what was being thought of at the time of task creation and task requirements..)
Line 54:
 
What do you think Gerard? --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 08:07, 16 September 2018 (UTC)
 
 
: First, I used the initializations of several variables to show that values (and expressions) should be able to be used within the constructs shown.   This by-passed the static or hard-coding of values within the iteration ranges.   -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 09:37, 16 September 2018 (UTC)
 
 
: I definitely wasn't thinking of an easy way to loop around a block (or blocks) of code, if fact, this is exactly what I was trying to avoid, that is, avoiding logic which avoids going around code (to avoid execution of some code ─── this seems/appears to an anathema to structured programming)   by some kind of artificial construct,   or even using logic to chose which block to execute (or not execute).   Specifically, I wanted a "pure"   '''do'''   construct   (or   '''for'''   construct)   if possible.   I was only interested in methods that directly stated what was intended (that is, if it was possible to write code in that manner).   I had, in fact, originally wrote the REXX version to do exactly what the PL/I language used, but it involved writing a function to essentially parse (scan) for the appropriate clauses   ('''to''', '''by''', '''which''', '''for''', '''until''', ...   in any order)   and execute the   '''do'''   index variable accordingly ─── but the amount of code seemed to be a tad bit bulky and had to deal with too many (error/omission) issues, and it made the program hard to follow and understand, defeating the purpose of a (clean-looking)   '''do'''   loop with multiple (iteration) ranges.   I may end up including it as an alternative solution with the usual "your mileage may vary" caveat.   I have often come across the need for a multiple-range   '''do'''   loop structure, and once you've used it, it comes very natural to think (and code) in that manner,   --- but in any case, it's easy to program around any deficiency or short-coming of a language, but I wanted to see how other programming languages dealt with such an animal, or failing that, how programmers dealt with that type of logic to perform the same function/need.   One thing that I definitely wanted was to use expressions instead of hard coded start/stops/increments   (or however one wanted to express such a range construct).   I think using functions   (as one form of expressions or within expressions)   really muddies up the waters   (but it covers the ground!)   when writing pseudo-code, even in a general manner such as this.   I had assumed that programmers could understand the use of functions instead or embedded within an expressions, but I didn't think that would make it any clearer.   Also note that I didn't assume that many languages supported such a structure, so part of the Rosetta Code's task requirement stated that other "work-arounds" may be used if   '''do'''   loops with multiple ranges weren't possible.   I also had to deal with several types (kinds) of   '''do'''   loop (incrementing/decrementing) ranges, and also the "step" or   '''by'''   values, and to make sure that expressions could be used instead of hard-coded values, and to also ensure that every computer programming solution did the exact index enumerations, so I had to Jerry-rig a method to validate the   '''do'''   index   (in this case,   '''j''').   I had to add a somewhat complicated   '''if'''   statement so that the product wasn't zero, and also so that the product didn't exceed the limit(s) of an integer for most programming languages.   I was going to have the programming examples just display all the values of the   '''j'''   index, but it takes a lot of eyeballing to verify a list of numbers   (even a horizontal list),   whereas observing just two values makes it easy to verify that the   '''do'''   loop index was incremented and/or decremented correctly.   I threw in the commatizing the two (output) results as a more-or-less optional requirement for programmers that wanted to walk an extra few paces ─── I always appreciated those Rosetta Code tasks that had an optional or "extra" credit thingy.   -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 09:37, 16 September 2018 (UTC)
 
==other DO loop cases==