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

Using arguments in Icon procedures

Tech Computer Center logo

Each Icon procedure starts with the keyword procedure followed by the name of the procedure, and a pair of parentheses enclosing the arguments to the procedure. Here is an example of a procedure that computes the function C(n,k) = n!/(k!(n-k)!), the number of combinations of n different objects taken k at a time:

procedure C(n,k)
#--
# Returns the number of combinations of n things taken k at a
# time, given by C(n,k) = n! / ( k! * (n-k)! )
#--
  return Factorial ( n ) /
    ( Factorial ( k ) * Factorial ( n - k ) );
end
The statement ``return e'' computes the value of the expression e and exits the procedure, substituting the value of e into the calling expression at the location in the program where the procedure was invoked.

(See the previous page, `Using procedures in Icon', for the Factorial() procedure.)


Next: Branching in Icon
See also: A tutorial for the Icon programming language
Previous: Using procedures in Icon
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/procargs.html
QR two-dimensional bar code