There are a bunch of different kinds of thing that can hold a collection of other things.
A list and array are pretty similar and is like a checklist of stuff, in that they are in order and we can add to the bottom or insert an item into the middle whenever we like.
A sequence is like some things coming off an assembly line. We don’t know how many they are (it could be infinite!!) and we take them as they come.
A set is more like a bag of things where no two things in the bag can have the same value.
We’ll generally use a List for our collections of things because it has some useful operators to join and split the list:
[1; 2; 3] @ [8; 9; 10] = [1; 2; 3; 8; 9; 10]
a
is the first thing in the list and b
is all the rest. Really useful when you’re processing each thing in the list in turn.A hand of cards is just a list of Card
things
let hand = [Hearts Three; Diamonds Ten; Clubs King; Joker]
type CardNumber =
| Two
| Three
| Four
| Five
| Six
| Seven
| Eight
| Nine
| Ten
| Jack
| Queen
| King
| Ace
type Card =
| Hearts of CardNumber
| Diamonds of CardNumber
| Clubs of CardNumber
| Spades of CardNumber
| Joker
let hand = [Hearts Three; Diamonds Ten; Clubs King; Joker]