What is the effect of "Seq" on "seq"?

I worry when I do not know when you can use "Seq", "seq". Can you tell me which of these consequences?

This is my code. Why aren't you using "seq"?

 let s = ResizeArray<float>()
 s.Add(1.1)
 s.Add(2.2)
 s.Add(3.3)
 s.Add(4.4)
 s |> Seq.iter (fun x -> printfn("%f") x )
+4
source share
2 answers

Seqis a module that contains functions that work with values Seq:

Seq.map string [ 1; 2 ]
Seq.sum [ 1; 2 ]

Seq is a type name:

let f1 (xs : seq<int>) = ()
let f2 (xs : int seq) = ()

Seqalso a function that converts something like a list to a type Seq:

seq [ 1; 2 ]

seq { ... } is an expression:

seq { yield 1; yield 2 }
+8
source

You use uppercase Seq in all cases except type annotations. For instance:

let (x:seq<int>) = 
    [1..10]
    |> Seq.map (fun t -> t + 1)

Edit: see recommended answer as my answer is incomplete.

+2

Source: https://habr.com/ru/post/1683080/


All Articles