Next: , Previous: DC, Up: Commands


10.3.10 Define: Define a function

General Form:

          define function(arg1, arg2, ...) expression

Define the user-definable function with the name function and arguments arg1, arg2, ... to be expression, which may involve the arguments. When the function is later used, the arguments it is given are substituted for the formal arguments when it is parsed. If expression is not present, any definition for function is printed, and if there are no arguments to define then all currently active definitions are printed. Note that you may have different functions defined with the same name but different arities.

Some useful definitions are:

          define max(x,y) (x > y) * x + (x <= y) * y
          define min(x,y) (x < y) * x + (x >= y) * y