Branching in Icon
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 (
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 Shipman, firstname.lastname@example.org
Last updated: 1996/01/06 21:12:57 UT