> <\body> Any function definition can be preceded by the quantifier .... A function definition is done as follows: <\mmx-code> name arg1: type1, arg2: type2, ...: returned_type == ... also provides a syntax for lambda expressions: <\mmx-code> (arg1: type1, arg2: type2, ...): returned_type ... Notice that any of the type specifications can be omitted, in which case the type is assumed to be .\ <\mmx-code> discr (a, b, c) == b^2 - 4*a*c; \; forall (R) gcd (p: Polynomial(R), q: Polynomial(R)): Polynomial(R) == {...} A macro corresponds to a syntactic definition and can be introduced by using >. Expression macros can also be defined by using instead of . No type is needed: <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> square x ==\ x*x <|unfolded-io> <\unfolded-io> <|unfolded-io> square 2.1 <|unfolded-io> <\unfolded-io> <|unfolded-io> square 2 <|unfolded-io> <\unfolded-io> <|unfolded-io> disc (a,b,c) ==\ b*b - 4*a*c\ <|unfolded-io> <\unfolded-io> <|unfolded-io> disc (1,2,3.001) <|unfolded-io> A function or a macro is called in the usual way: . If is unary then can be omited, but note that is equivalent to . Function call is always by value. The definition of a postfix function is preceded by the keyword . The name of the function should start with a ''. <\session|mathemagix|default> <\input> <|input> postfix .square (i : Int) : Int == i*i; <\unfolded-io> <|unfolded-io> 3.square <|unfolded-io> <\input> <|input> postfix .m (a: Int) (b: Int) : Double == 1.0 * a * b; <\unfolded-io> <|unfolded-io> 3.m 3 <|unfolded-io> Functions can be treated like other objets. Nested functions are supported by . <\session|mathemagix|default> <\input> <|input> shift (x: Int) (y: Int): Int == x + y; <\unfolded-io> <|unfolded-io> shift 3 <|unfolded-io> <\unfolded-io> <|unfolded-io> (shift 3) 4 <|unfolded-io> <\unfolded-io> <|unfolded-io> map (shift 3, [ 1 to 10 ]) <|unfolded-io> > . If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.> <\with|font|roman> \;