Defining and Using a Custom Operator |
You can define an operator in much the same way you define a function. Typically, it's best to use a special symbol for the operator name, but otherwise the process is the same. The difference is in the way you apply a custom operator. Mathcad gives you special operators for calling functions so that they can have operator-like notation: infix, prefix, or postfix.
| Defining a Custom Operator |
Custom operators can be unary, with one argument, or binary, with two arguments. For example, ! (factorial) is a unary operator, while + (addition) is a binary operator. To define a unary operator:
Define the operator as a function.
Type [:] to see the definition symbol, :=. A placeholder appears.
In the placeholder, type an expression involving the operand.
To define a binary operator, make a function of two variables instead of one.
| Using a Custom Operator |
To use the function as an operator, open the Evaluation toolbar containing the custom operator notation buttons. If your function is unary, you need to choose whether you wish to see the operator before the operand (prefix notation), or after (postfix notation).
In the remaining placeholder, type the operand.
If your function is binary, you can choose to use the operator between the operands (infix notation), or above them in a tree structure (treefix notation).
Infix |
Treefix |