# Sets, Sequences and Tuples

If you are not sure about the differences between sets, sequences and tuples, here they are:

Sequences: A sequence is an ordered list of elements, which can also be infinite (e.g., the sequence composed of the real numbers). Since order of elements matter, the sequence (1,2,3) is different from the sequence (1,3,2) or from the (3,2,1) one.

You may also have an empty sequence (), and you may also have repeated elements. For instance, (1,1,1) is a sequence.

A subsequence is found by deleting some (which might be none or all) elements of the sequence, while keeping the order of the others.

Tuples: A tuple is also an ordered list of elements, and it also may include repeat elements. The only difference between sequences and tuples is that tuples have a finite number of elements necessarily, while sequences might have finite or infinite elements.

A tuple with n elements is called an n-tuple.

Sets: A set is a collection of unique objects, so elements cannot be repeated (you can relax this constraint by calling it a multiset).

So {1,2,3} is a set but {1,1,2,3} is not.

Additionally, the order of the elements does not matter, so {2,4,6} is the same set as {6,2,4}.

A subset of a given set is found by removing some of its members (once again this can be all or none of the members). The collection of all subsets of a set is called powerset.

Finally, notice that sequences and tuples are usually written inside parenthesis, while sets are written inside braces.

## One thought on “Sets, Sequences and Tuples”

1. kemiisto

I’m quite interesting in what you said about the difference between tuples and sequences. But it seems like it just a tradition that tuples are usually finite while sequences are usually infinite. At least i was unable to find such a strict definitions.