Google News
logo
F# - Interview Questions
What is collection types in F#?
By reviewing this topic, you can determine which F# collection type best suits a particular need. These collection types differ from the collection types in .NET, such as those in the System.Collections.Generic namespace, in that the F# collection types are designed from a functional programming perspective rather than an object-oriented perspective. More specifically, only the array collection has mutable elements. Therefore, when you modify a collection, you create an instance of the modified collection instead of altering the original collection.
 
Collection types also differ in the type of data structure in which objects are stored. Data structures such as hash tables, linked lists, and arrays have different performance characteristics and a different set of available operations.
 
Table of collection types :
The following table shows F# collection types.

Type Description Related Links
List An ordered, immutable series of elements of the same type. Implemented as a linked list. List Module
Array A fixed-size, zero-based, mutable collection of consecutive data elements that are all of the same type.
Array Module

Array2D Module

Array3D Module
seq A logical series of elements that are all of one type. Sequences are particularly useful when you have a large, ordered collection of data but don't necessarily expect to use all the elements. Individual sequence elements are computed only as required, so a sequence can perform better than a list if not all the elements are used. Sequences are represented by the seq<'T> type, which is an alias for IEnumerable. Therefore, any .NET Framework type that implements System.Collections.Generic.IEnumerable<'T> can be used as a sequence. Seq Module
Map An immutable dictionary of elements. Elements are accessed by key. Map Module
Set An immutable set that's based on binary trees, where comparison is the F# structural comparison function, which potentially uses implementations of the System.IComparable interface on key values. Set Module
Advertisement