News flash: I'm going to Australia in February, so this Web site may be switched off at any time.
Here's a short program that illustrates conditional branches in Icon:
procedure main() if 1 < 2 then write ( "One is less than two" ) else write ( "One is greater than two" ); endThe general form is ``
if e1 then e2 else
e3
'', meaning ``if e1 produces at least
one result, evaluate e2, otherwise evaluate e3.''
The less-than operator (e1<e2
)
means, ``if e1 is less than e2, produce the value
of e2, otherwise produce no values at all.''
An Icon expression that produces no values is said to fail. This concept of failure is actually one of the cleanest and most useful features of Icon, in the author's opinion.
john@nmt.edu