4 ms·
Would you expect to see a for loop in a mathematical equation? You're correct in noticing that a lot of the reasons why you'd use a for loop are taken care of w
by formalsystem 12y ago
Would you expect to see a for loop in a mathematical equation? You're correct in noticing that a lot of the reasons why you'd use a for loop are taken care of with basic functions such as map (to perform some action on different elements in a list), reduce (to do some sort of aggregation).
So you kinda just don't need for loops anymore and they're inherently imperative because you need to setup some sort of condition to say keep performing this sequence of actions (which is the main idea behind imperative programming) until this condition is no longer satisfied.
- rifung 12y agoAh I guess that is true! There's no reason to have them unless you need them since it would make the language simpler. Also I am beginning to see that loops actually can lead to programs which are hard to reason with, so if anything I guess they would want to not include them unless absolutely necessary.
- j13z 12y agoMaybe think about it this way: Loops are not expressions. (Where I assume that you are talking about for-loops and the like.)