Application Center - Maplesoft

# Maple Programming: 4.6: Maple functions are procedures

You can switch back to the summary page by clicking here.

4.06.mws

Programming in Maple

Roger Kraft
Department of Mathematics, Computer Science, and Statistics
Purdue University Calumet

roger@calumet.purdue.edu

4.6. Maple functions are procedures

A function in Maple is really like a procedure. Below we define a procedure,  a Maple function, and an expression, each of them equivalent to the mathematical function .

 > f1 := x^2+2*x-1;    # The mathematical function as an expression,

 > f2 := x->x^2+2*x-1; # as a Maple function,

 > f3 := proc(x)       # as a procedure.

 > x^2+2*x-1

 > end;

Let us see how Maple remembers the definitions of   f1 ,   f2 , and   f3 .

 > eval( f1 );   # f1 was defined as an expression.

 > eval( f2 );   # f2 was defined as a function.

 > eval( f3 );   # f3 was defined as a procedure.

Check the data types of f1 , f2 , and f3 .

 > whattype( eval(f1) );   # f1 was defined as an expression.

 > whattype( eval(f2) );   # f2 was defined as a function.

 > whattype( eval(f3) );   # f3 was defined as a procedure.

Notice that Maple considers both f2  and f3  to be of type procedure , so Maple treats functions as procedures.

 >

 >