## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Iteration

Even something as simple as a for-loop iterating over data performing work can be enhanced by GCD. The classic way of iterating through an array and performing an operation on each element is through a for loop.

```e​n​u​m​ ​{​
​ ​ ​ ​k​N​u​m​b​e​r​C​o​u​n​t​ ​=​ ​2​0​0​0​0​0​
}​;​

s​t​a​t​i​c​ ​i​n​t​ ​n​u​m​b​e​r​s​[​k​N​u​m​b​e​r​C​o​u​n​t​]​;​
s​t​a​t​i​c​ ​i​n​t​ ​r​e​s​u​l​t​s​[​k​N​u​m​b​e​r​C​o​u​n​t​]​;​

f​o​r​ ​(​i​n​t​ ​i​ ​=​ ​0​;​ ​i​ ​<​ ​k​N​u​m​b​e​r​C​o​u​n​t​;​ ​i​+​+​)​ ​{​
​ ​ ​ ​r​e​s​u​l​t​s​[​i​]​ ​=​ ​W​o​r​k​ ​(​n​u​m​b​e​r​s​,​ ​i​)​;​
}​
```

You could walk through the array doing work that is not really interrelated and then sift through the work to make the final conclusion, like a map/reduce operation.

You can ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required