Node:Prefix and postfix functions, Next:, Up:Functions



Prefix and postfix functions

A prefix function can take any number of parameters specified after the function name:

:(F :x1 :x2)=x1-x2   # Definition of function F.
F 10 3               # Call of function F; yields 7.

A postfix function takes a single parameter specified before the function name:

:(:arg G)=arg*arg    # Definition of function G.
5 G                  # Call of function G; yields 25.

It is also possible for a function to take parameters specified both before and after the function name. This allows infix functions:

:(:x mod :y) = x - y*floor(x/y)
-8 mod 3 # Yields 1.
The arguments before the function name are called the left parameters, while those after are called the right parameters. In the mod example, x is a left parameter, and y is a right parameter.

Having both prefix and postfix functions could lead to ambiguity. See <not written> on the details.