News flash: I'm going to Australia in February, so this Web site may be switched off at any time.
The general form of the ``every'' loop in Icon is:
every e1 do e2This means, every time expression e1 produces a result, evaluate expression e2.
The ``do e2
'' part is optional.
The expression ``every e1
'' means: compute every result
of 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 e and add it to the
current value of variable v.
john@nmt.edu