Iteration Iteration

Iteration - Definition and Overview

Related Words: Copy, Copying, Critique, Doubling, Gemination, Imitation, Recapitulation, Reduplication, Repetition, Replication

Iteration is the repetition of a process, typically within a computer program. Confusingly, it can be used both as a general term, synonymous with repetition, and to describe a specific form of repetition with a mutable state.

When used in the first sense, recursion is an example of iteration.

However, when used in the second (more restricted) sense, iteration describes the style of programming used in imperative programming languages. This contrasts with recursion, which has a more declarative approach.

Here is an example of iteration, in imperative pseudocode:

 var i, a := 0        // initialize a before iteration
 for i from 1 to 3 {  // loop three times
     a := a + i       // increment a by the current value of i
 }
 print a              // the number 6 is printed

In this program fragment, the value of the variable i changes over time, taking the values 1, 2 and 3. This changing value—or mutable state—is characteristic of iteration.

Iteration can be done in functional programming languages. The following example is in Scheme:

(define (sum n)
	(define (iter i result)
    (if (<= i n)
        (+ i (iter (+ i 1) result))
        result))
    (iter 0 0))

An iterator is an object that wraps iteration.

See also

Example Usage of Iteration

TI3GIB: @muscati Not sure. I sort of read up on him when the Mini came out. BMW changes designer with every Iteration of their cars.
cipher: RT @feedly: RT @edwk: New design Iteration of the feedly cover http://bit.ly/5Oyd1h [here is a screenshot]
DesignRT: RT: RT @edwk: New design Iteration of the feedly cover http://bit.ly/5Oyd1h [here is a screenshot] http://bit.ly/6QfYh1
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.