t> SETS AND LISTS
b>
t> Now that we have learned how the create expressions and expression
t> sequences, it is time to put those skills to use in creating the next
t> level of Maple objects: sets, lists, and tables. These three data types
t> all lend organization to Maple expressions, though the exact manner in
t> which they do so varies between the three structures.
b>
c1>
t> Sets
b>
t> A set is a non-ordered collection of expressions. Any valid Maple
t> expression can be contained in a set. Sets are often used as input to a
t> Maple procedure and are frequently contained in Maple output.  A set is
t> written as an expression sequence surrounded by braces, {}.  One
t> important consideration to remember about sets is that repetitive
t> elements are automatically removed. (This feature can be quite handy
t> for many programming tasks.) The first of the following three examples
t> demonstrates this "non-repetitive" rule.
b>
c1>
x> {1, 1, 2, 3, 2};
x> {a*x, my.name, -234.456, `Maple Tutorial!`};
h> {blue, red, white};
x> {red, white, blue};
b>
c1>
t> As you can see from the last two examples, the order in which you list
t> the elements of a set is not necessarily how Maple sees them internally.
t> But it is important to remember that for the rest of your Maple
t> session, those particular elements will continue to be seen internally
t> by Maple in the same order.
b>
c1>
t> There are three basic operators that work on sets: the "union" operator
t> combines the elements of two sets into one (eliminating any repetitive
t> elements, of course), the "intersect" operator creates a set that
t> contains any elements common to two sets, and the "minus" operator
t> removes from the first set any elements also found in the second set.
b>
x> {a, b, c, d} union {d, e, f};
x> {1, 2, 3, 4, 5} intersect {2, 4, 6, 8, 10};
x> {x1, x2, x3} minus {x1, y1};
b>
c1>
t> Questions
b>
c2>
q> Type the individual letters of the word "calculation" into a set to
q> obtain a listing of the different letters used in the word.
a> {c,a,l,c,u,l,a,t,i,o,n};
b>
c2>
q> Use sets to find the intersection of the first five odd numbers 
q> (starting at 1) and the first five prime numbers (starting at 2).
a> {1,3,5,7,9} intersect {2,3,5,7,11};
eoq>
b>
c1>
t> Lists
b>
t> Though similar in syntax, lists and sets have significant differences.
t> Both sets and lists are defined by expression sequences, but lists are
t> enclosed with right and left brackets, []. Lists are "well-ordered"
t> objects, meaning that when you specify a list in Maple the ordering
t> that you indicated is preserved. Another fundamental difference is that
t> duplicate elements are valid within a list. Following are some examples
t> of lists.
b>
c1>
x> [1, 2, 3, 4, 5, 4, 3, 2, 1];
x> [a, d, c, b, e];
x> [{c,a,t}, {d,o,g}, {m,o,u,s,e}];
t> In the last example, each of the three sets is an element of the list
t> enclosing them. While the ordering of the elements within the sets may
t> vary, the ordering of the three sets themselves remains constant.
b>
c1>
t> While the union, intersect, and minus operators do not work on lists,
t> the commands op and nops may be used to access and manipulate elements
t> of a list. (There will be more explanation of these routines in a
t> future section of this tutorial.)
b>
c1>
t> Questions
b>
c2>
q> Create a list containing the letters "a" through "j" in alphabetical order.
a> [a,b,c,d,e,f,g,h,i,j];
b>
eoq>
eof>


