February 19, 2017 Leave a comment
Lists in F# are type safe and immutable. Type safety means that all elements in the list must be of the same type. Immutability implies that once the list is created we cannot add new elements to it. Instead, a new list will be created with the elements of the old list copied to the new list along with the new value(s) we want to add to it.
Here’s how to declare an empty list:
let myFirstList = ;
The ‘::’ operator is used to add a new item to the head of the list: