Neutral Operators (User-defined Operators) - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Operators : neutral

Neutral Operators (User-defined Operators)

 

Description

Examples

Description

• 

There are two forms of neutral operators: alphanumeric and symbol.

  

An alphanumeric neutral operator begins with an ampersand (&), followed by a letter or underscore, optionally followed by further letters, digits, or underscores.

  

A symbol neutral operator begins with an ampersand, followed by one of these special characters:

! " $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ ` { | } ~

  

optionally followed by further characters from this set:

! " $ ) * + , - . / < = > ? @ \ ] ^ | } ~

• 

Neutral operators can be used as unary prefix operators, binary infix operators, or as function calls. They generate function calls, with the name of the function the same as the name of the neutral operator.

• 

With the exception of &*, the neutral operators all have the same precedence. The &* operator has lower binding strength. For more information about the precedence of neutral operators in relation to other operators, see operators/precedence.

• 

Most binary neutral operators are left-associative, except those beginning with two ampersands (&&), which are right-associative.

• 

Maple imposes no semantics on the neutral operators. The user may:

– 

define manipulations on expressions containing such operators via Maple's interface to user-defined procedures for various standard library functions, including simplify, diff, series, evalf, expand, and so on. (See the help pages for the appropriate library functions.)

– 

write procedures with the same names as the neutral operators, in which case expressions using those operators will invoke the procedures.

– 

write modules exporting procedures with the same names as the operators, and then bring these operations into scope with use, uses, or with.

  

Note: Because ~ is a valid character in a symbol neutral operator, such an operator ending in ~ is not interpreted as an element-wise operator (see operators/elementwise). To apply a neutral operator element-wise, a space is required before the ~.

  

Note: Some neutral operators are currently not supported in 2-D input in the Standard interface. For more information on which ones, see the Neutral Operators section of updates/Maple2019/Language.

Examples

a &* b

a&*b

(1)

Neutral operators have higher precedence than other operators.

ab &+ c

ab&+c

(2)

All neutral operators except &* have the same precedence.

a &- b &/ c

a&−b&/c

(3)

Neutral operators can be used in function-call form.

`&-`a&comma;b&comma;c&comma;d

&-a&comma;b&comma;c&comma;d

(4)

a &xx ba &xx b

0

(5)

Neutral operators beginning with && are right-associative.

a &&- b &&/ c;

a&&−b&&/c

(6)

A space is needed before the ~ to apply a neutral operator element-wise.

[a,b,c] &*~ [d,e,f];

a&comma;b&comma;c&*˜d&comma;e&comma;f

(7)

[a,b,c] &* ~ [d,e,f];

a&*d&comma;b&*e&comma;c&*f

(8)

Defining a procedure with the same name as a neutral operator allows the introduction of user-defined prefix and infix operators.

`&str` := proc( ) cat("",_passed) end proc:

`&str`a

a

(9)

a &str b &str c

abc

(10)

See Also

define

operators/elementwise

operators/precedence