Macaulay2 » Documentation
Packages » Macaulay2Doc > The Macaulay2 language > operators > ->
next | previous | forward | backward | up | index | toc

-> -- make a function


x -> e -- denotes a function. When the function is called, the initial value of the variable x is the argument if there is just one, or else is the sequence of arguments.
(x) -> e -- denotes a function of one argument. When the function is applied to an expression w three things may happen:
(x,y) -> e -- denotes a function of two arguments.

Similarly for more arguments.

These operations create what is usually called a closure, which signifies that the function remembers the values of local variables in effect at the time of its creation, can change those values, and share the changes with other functions created at the same time.
i1 : f = x -> 2*x+1

o1 = f

o1 : FunctionClosure
i2 : f 100

o2 = 201
The class of all functions is Function.

For the programmer

The object -> is a keyword.