Tutorial by Examples

There are multiple ways to create a sequence. You can use functions from the Seq module: // Create an empty generic sequence let emptySeq = Seq.empty // Create an empty int sequence let emptyIntSeq = Seq.empty<int> // Create a sequence with one element let singletonSeq = Seq.s...
A sequence is a series of elements that can be enumerated. It is an alias of System.Collections.Generic.IEnumerable and lazy. It stores a series of elements of the same type (can be any value or object, even another sequence). Functions from the Seq.module can be used to operate on it. Here is a s...
let seq = seq {0..10} s |> Seq.map (fun x -> x * 2) > val it : seq<int> = seq [2; 4; 6; 8; ...] Apply a function to every element of a sequence using Seq.map
Suppose that we have a sequence of integers and we want to create a sequence that contains only the even integers. We can obtain the latter by using the filter function of the Seq module. The filter function has the type signature ('a -> bool) -> seq<'a> -> seq<'a>; this indicat...
let data = [1; 2; 3; 4; 5;] let repeating = seq {while true do yield! data} Repeating sequences can be created using a seq {} computation expression

Page 1 of 1