Traversing, Analyzing, and Generating Sequences of Data

When a program visits each element of a list of elements, programmers say the list is being traversed. Traversal is one of the most fundamental uses of iteration statements. The general loop construct for analyzing a list of data can be depicted by a flow chart or pseudocode as in Figure 9.1. Notice how the depiction matches our definition of an iteration statement presented in the beginning of the previous chapter: “An iteration statement repeats a statement or a block of statements until a given termination condition is met.”

Figure 9.1. An iteration construct used for analyzing a sequence of data elements.

Figure 9.2 illustrates the general framework for a loop generating a list of data ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.