Next: Scope Rules: Parameters Up: Maple Procedures Previous: Tracing Procedure Execution:

Arrow Operators

For procedures which compute only a formula, there is an alternative syntax called the arrow syntax. This mimics the syntax for functions often used in algebra. For functions of one parameter the syntax is

symbol -> [local nameseq;] expr .

For 0 or more parameters, parameters are put in parentheses i.e.

( nameseq ) -> [local nameseq;] expr

The example which computes can be written more succinctly as


(x,y) -> x^2+y^2;

In Maple V Release 2, the syntax has been extended to allow the body of the procedure to be an if statement. So you can define piecewise functions. For example


x -> if x<0 then 0 elif x<1 then x elif x<2 then 2-x else 0 fi;


Klaus Steinberger
Mi Apr 13 12:51:51 MDT 1994