## Using the ``every'' construct in Icon |

The general form of the ``every'' loop in Icon is:

everyThis means, every time expressione1doe2

The ```do `

'' part is *e2***optional**.
The expression ```every `

'' means: compute every result
of *e1**e1* in sequence, discarding each one.

We can rewrite the simple arithmetic program this way:

procedure main() local sum # Declare a variable for the sum sum := 0; # Set the sum to zero every sum +:= 1 to 5; write ( "The sum of all numbers from 1 to 5 is ", sum ); endThe construct ``

*v* +:= *e*

'' means:
compute the value of expression 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/usingevery.html |