## How expressions work in Icon |

There are two important properties of Icon expressions:

- Icon has no statements, just expressions.
- In general, an expression is
**a sequence of operations that may produce zero or more results**.

In general, Icon loops take the form
```every `

''
where *e1* do *e2**e1* and *e2* can be any expression.
If *e1* produces no results, *e2* is never
evaluated. If it produces 19 results, *e2* is evaluated
19 times, and so on.

Let's take another look at the loop in the simple arithmetic program:

every n := 1 to 5 do # For n equal to 1, 2, 3, 4, 5 ... sum := sum + n; # ...add n to the sumIn this case, the expression ``

`n:=1 to 5`

'' produces
five results, so the loop is executed five times. The expression
```1 to 5`

'' produces the values from 1 to 5 in sequence.
Site map

To report a problem:

Send mail to the

John Shipman, john@nmt.edu
Last updated: 1996/01/06 21:12:57 UTURL: http://www.nmt.edu/tcc/help/lang/icon/howexpr.html |