Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

Branching in Icon

Tech Computer Center logo

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" );
    end
The 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.


Next: The joys of failure in Icon
See also: A tutorial for the Icon programming language
Previous: Using arguments in Icon procedures
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Information Technology and Communications: Help System
ITC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

John Shipman, john@nmt.edu
Last updated: 1996/01/06 21:12:57 UT
URL: http://www.nmt.edu/tcc/help/lang/icon/branching.html
QR two-dimensional bar code