
Foreach is a loop, similar to "for" or "while". It's used like this:

foreach (string s in strs) {
  write(s+"\n");
}

In this example, strs is an array of strings. Starting at strs[0] and
going up, s is set to each element, then the body (write, in this case)
is run. This is useful because most of the time, with an array,
you just want to do something to each element. "For" loops are often used
for this, but they are harder to read and not quite as fast.

Note that foreach can work on any data type that you can make into
an array, and it can even work on mappings, like so:

foreach (string k, int v in somemapping) {
  write("key: "+k+", value: "+v+"\n");
}

The variables you define in the foreach (s, k, and v in the examples)
only exist inside the loop.

Using a combination of foreach and filter, we can do almost everything
for which the "for" or "while" loops are often used, but faster
and easier to read.
