Introduction
Creating a Vector
Initializing an Empty Vector
Accessing an Element
Appending an Element
Prepending an Element
Vector Concatenation
Introduction
Like Lists, Vectors are another immutable collection of sequence type. They differ in the fact that Lists are linear while Vectors are indexed. What this means is that if you want to access a central element in a List, the compiler has to start from the beginning and linearly progress through the List until it finds the element you are trying to access. However, when you want to access a central element in a Vector, the compiler can directly go to that index and access the element in constant time.
While Lists should be used when you only plan to manipulate the head element (first element), Vectors provide efficient access when you want to manipulate elements beyond the head.
Creating a Vector
Vectors can be created using the Vector keyword followed by ().