The Concept of Sequence in F# defines that a Sequence is a collection of Elements or Series of Elements. All elements of a Sequence will be of the same type. Sequences are used and useful when you need to operate on a huge amount of data. Sequences are commonly known as Sequence Expressions and are similar to Lists, but when not all elements are used the performance of a Sequence is better than Lists. Both Data structures are used to represent an ordered collection of Elements.
For Lists all elements are computed at once whereas elements of a Sequence are computed when needed. This provides some interesting properties for Sequences such as the ability to represent an Infinite data structure and Lazy evaluation. Sequences are represented by seq<T>type which is an Alias for IEnumerable(T). A seq<type> is simply a value that can be iterated, producing results of type "type" on demand. Sequences are used to wrap computations, collections and data streams and are frequently used to represent the results of database queries. Syntax for Defining a Sequence The syntax for defining a Sequence is as follows:
seq { expr }
seq { 0 .. 20 .. 40 .. 100 }
let newSeq = seq {cexpr}
let list = seq { 1..5 } |> //Seq.to_list
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: