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;

The restriction of the body of the procedure to expr an expression means that you cannot have an if statement. So you cannot define piecewise functions. For example, Maple will not allow


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


bondaren@thsun1.jinr.ru