What is Maple and what can it do?
First, Maple is a glorified calculator and it can do arithmetic operations.
> 3+4;
> 37*555;
> 2^1024;
Every object in Maple is essentially one of: a number, a name, a list, a set, or a procedure. Some examples of valid expressions are below. Pressing enter evaluates the expression and the symbol "%" refers to the last expression evaluated.
> sort([5,2,1,5,4,3,1,3,2]);
> sort({5,2,1,5,hi,3,1,3,2,4,bye});
> din:=1363/144.;
> din^4;
> sqrt(sqrt(%));
The language of Maple is based on PASCAL. It has many of the same elements but there are major differences. The following is a list of commands that I use on a regular basis:
seq- create a sequence of expressions separated by commas
> seq(i^2-10*i+20,i=1..10);
> mylst:=[seq(i^2-10*i+20,i=1..10)];
> myset:={seq(i^2-10*i+20,i=1..10)};
> [seq(evalb(x<0),x=mylst)];
nops - number of operations - returns the length of a list or size of a set
> nops(mylst);
> nops(myset);
for ### do od; - this is the for loop. You can either loop "for each element in a list or set" or "for a variable running from a value to a value." The word "od" marks the end of the for-do loop (alternatively, od can be replaced by "end do").
>
for i from 1 to 10 do
evalb(i^2-10*i+20<0);
od;
if ### then else fi; - if an expression evauates to true then execute the first statement, otherwise execute the second statement
>
d:=5;
if d<6
then print("less");
else print("more");
fi;
proc( names ) local vars; ### end; - this is the notation for a procedure the last line of the procedure is the value that is returned (unless a RETURN(####); command is encountered).
>
myfunc:=proc(x);
evalb(x<0);
end;
> myfunc(4);
(names)-> ####; - This is a shorthand notation for a procedure, there can be no local variables using this shorthand notation
> myfunc2:=x->evalb(x<0);
> myfunc2(-4);
map - applys a function to every element in a list
> map(myfunc,mylst);
> map(myfunc2,mylst);
>