## COMP203: Lecture 17

#### Logo Project due today.

Email me a copy of your code if you've had trouble completing yours.
## Sets, Lists and Sequences

In Logo, there is a big difference between (print sum 2 3 4) and [print sum 2 3 4]. The parentheses tell Logo that the output of sum and the number 4 are inputs to print. The square brackets enclose a list in Logo, which Logo will only evaluate under certain circumstances.

### Sequences

You saw examples of sequences Maple Basics 2: the output of solve() is often a sequence:
b) Use Maple to solve the equation
3 2
x - 9 x + 26 x - 24 = 0.
> solve(x^3-9*x^2+26*x-24 = 0, x);
2, 3, 4

Here 2, 3, 4 is a sequence of numbers. Notice that there are no parentheses or brackets around the sequence.
### Lists

In Logo, lists were enclosed in square brackets: []. The same is true in Maple. In Maple, we separate the elements of a list using commas.
[2, 3, 4]

is a list.
### Sets

Unlike many computer programs, Maple also understands mathematical sets. These look like sequences enclosed in curly brackets: {}. The snippet of Maple code below demonstrates that the set {1, 2, 3} is the same as set {1, 1, 2, 2, 3} in Maple -- repeated elements are ignored.
> if {1, 2, 3} = {1, 1, 2, 2, 3} then print(these are equal) end if;
these are equal
> if {1, 1, 2} = {2, 2, 2} then print(these are equal) end if;
>