Difference between revisions of "Loop (computing)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
 
Line 31: Line 31:
  
 
* [https://en.wikipedia.org/wiki/Control_flow#Loops Control flow: Loops] @ Wikipedia
 
* [https://en.wikipedia.org/wiki/Control_flow#Loops Control flow: Loops] @ Wikipedia
 +
 +
[[Category:Computer programming]]
 +
[[Category:Computer science]]
 +
[[Category:Computing]]

Latest revision as of 06:37, 25 April 2016

In computing, a loop is a sequence of statements which is specified once but which may be carried out several times in succession.

Description

The code "inside" the loop (the body of the loop, shown below as xxx) is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met, or indefinitely.

In functional programming languages, such as Haskell and Scheme, loops can be expressed by using recursion or fixed point iteration rather than explicit looping constructs. Tail recursion is a special case of recursion which can be easily transformed to iteration.

Examples

Various types of loop exist:

  • Count-controlled loops
  • Condition-controlled loops
  • Collection-controlled loops
  • General iteration
  • Infinite loops
  • Continuation with next iteration
  • Redo current iteration
  • Restart loop
  • Early exit from loops
  • Loop variants and invariants

See also

External links