Sets, Lists, some basics.

A set is denoted by {} and a list by []. Both may be empty.

> S1:= {}; S2 := {1, 23}; S3 := {23,4,5};

S1 := {}

S2 := {1, 23}

S3 := {4, 5, 23}

Union, intersection and minus (set difference) can be accomplished two ways. Notice the back quote. The second form is more compact for more than two sets.

> T1 := S2 union S3; T2 := `intersect`(S2, S3,T1);

T1 := {1, 4, 5, 23}

T2 := {23}

You can test for membership and the result is of type boolean.

> b := member(1, S1); c := member(1, S2);

b := false

c := true

>

> type(b,boolean);

true

> b and c;

false

Lists

> L1 := [2,3,5,2,3,6,2,3]; L2 := [3,4,8,9];

L1 := [2, 3, 5, 2, 3, 6, 2, 3]

L2 := [3, 4, 8, 9]

> nops(L1); op(3,L1); [op(1..6,L1)]; {op(1..6,L1)};

8

5

[2, 3, 5, 2, 3, 6]

{2, 3, 5, 6}

> convert(L1,set);

{2, 3, 5, 6}

> L3 := [op(L1),op(L2)];

L3 := [2, 3, 5, 2, 3, 6, 2, 3, 3, 4, 8, 9]

> L3 := map(x -> x^2, L2);

L3 := [9, 16, 64, 81]