## Glossary

Select one of the keywords on the left…

# Sets and functionsLists

Sets are data containers with very little structure: you can check membership (and perform membership-checking-related operations like unions or complements), but that's all. We will define various other types of collections which provide additional structure.

For example, suppose you do care about the order in which the items appear on your grocery list; perhaps because you want to be able pick the items up in a certain order as you move across the store. Also, you might want to list an item multiple times as a way of reminding yourself that you should pick up more than one. Lists can handle both of these extra requirements:

Definition (List)
A list is an ordered collection of finitely many elements.

For example, if we regard and as lists, then they are unequal because the orders in which the elements appear are different. Also, the list has three elements, since repeated elements are not considered redundant.

We don't distinguish sets and lists notationally, so we will rely on context to make it clear whether order matters and repetitions count.

Exercise
How many sets have the property that ?

How many lists of length 4 have all of their elements in ?

Solution. There are 8 subsets of :

There are length-4 lists with elements in , because the set of such lists is equal to , and the cardinality of a Cartesian product of sets is the product of the cardinalities of the sets.

To reveal more content, you have to complete all the activities and exercises above.
Are you stuck? or reveal all steps

Next up:
Functions
Bruno