Talk:Loops/For with a specified step: Difference between revisions

From Rosetta Code
Content added Content deleted
("useless" examples?)
Line 1: Line 1:
The [[Ada]] solution might also consider using simple loop and then applying a (simple) function to generate the “loop variable”. For example, to loop from 0 to 10 by 2, you might loop from 0 to 5 by 1 and then set another var to the loop var times 2 at each step. (This technique is much more common when trying to loop by floating-point quantities, where feeding them directly into a [[C]]-like loop is inadvisable in many languages due to the need to manage imprecision in a way that doesn't blow up in your face...) —[[User:Dkf|Donal Fellows]] 23:38, 12 July 2009 (UTC)
The [[Ada]] solution might also consider using simple loop and then applying a (simple) function to generate the “loop variable”. For example, to loop from 0 to 10 by 2, you might loop from 0 to 5 by 1 and then set another var to the loop var times 2 at each step. (This technique is much more common when trying to loop by floating-point quantities, where feeding them directly into a [[C]]-like loop is inadvisable in many languages due to the need to manage imprecision in a way that doesn't blow up in your face...) —[[User:Dkf|Donal Fellows]] 23:38, 12 July 2009 (UTC)

== "useless" examples? ==
The recent purge https://rosettacode.org/mw/index.php?title=Loops%2FFor_with_a_specified_step&type=revision&diff=322790&oldid=322251 struck me as rather aggressive. What constitutes a "useless" example? Knowing that the for statement does ''not'' support a step of 2 could itself be useful. I feel those examples should be reinstated. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 11:40, 3 February 2021 (UTC)

Revision as of 11:40, 3 February 2021

The Ada solution might also consider using simple loop and then applying a (simple) function to generate the “loop variable”. For example, to loop from 0 to 10 by 2, you might loop from 0 to 5 by 1 and then set another var to the loop var times 2 at each step. (This technique is much more common when trying to loop by floating-point quantities, where feeding them directly into a C-like loop is inadvisable in many languages due to the need to manage imprecision in a way that doesn't blow up in your face...) —Donal Fellows 23:38, 12 July 2009 (UTC)

"useless" examples?

The recent purge https://rosettacode.org/mw/index.php?title=Loops%2FFor_with_a_specified_step&type=revision&diff=322790&oldid=322251 struck me as rather aggressive. What constitutes a "useless" example? Knowing that the for statement does not support a step of 2 could itself be useful. I feel those examples should be reinstated. --Pete Lomax (talk) 11:40, 3 February 2021 (UTC)