12.1 Introduction

Reflection: Iteration is repetition. When is this required and useful?

  • When is repetition useful? When we want to perform the same series of steps (process) on different data (inputs).

  • What is required for it?

Iteration is another method for abstraction: Carrying out a process repeatedly. Note the close relation between iteration and functions: Rather than constructing a loop, we could write a function and call this function repeatedly (with different inputs).

Any loop requires some criterion or condition that indicates wheter to continue and when to stop.