Chapter 2 - Maple Basics

2.7 Assignment

Maple can remember "things". That is, variables can be assigned values. These values can be anything, from an integer, a floating point number (a number with a decimal fraction), a string (set of characters), ..., even a plot. The syntax is:

variable := value;

where the assignment operator ":=" must be typed with no spaces ("=" is reserved to define an equation; this will be used later). For instance, the following commands assign various values to the indicated variables (the "#" is followed by comments):

 

The "restart" command starts the Maple compute engine anew. Doing this de-assigns all user defined variables.

The value of a variable is recalled by simply using the name of the variable in any valid Maple expressions; a variable on a line all by itself forces echoing the value of the variable.

Note that in the panel above, the second execution group will have to be run twice to see the given results. Do you know why? What would a "restart" (first in the execution group) do in this command? 

Using the right name for variables helps considerably to understand the logic of the work. For instance "m:=5" and "my_name:=`Vallières` seem fine, while "my_name:=5" is highly non intuitive.


 
Section 2.6 Chapter 2 Section 2.8       TOC

Any questions or suggestions should be directed to
Michel Vallières at vallieres@physics.drexel.edu