问题
I'm worried when don't know when you can use "Seq" , "seq" . Can you tell me which defferences are ?
This's my code . Why dont't use "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 )
回答1:
Seq
is a module that contains functions that work with seq
values:
Seq.map string [ 1; 2 ]
Seq.sum [ 1; 2 ]
seq
is a type name:
let f1 (xs : seq<int>) = ()
let f2 (xs : int seq) = ()
seq
is also a function that converts something like a list into the type seq
:
seq [ 1; 2 ]
seq { ... }
is a computation expression:
seq { yield 1; yield 2 }
回答2:
You use the uppercase Seq in all cases except in type annotation. For example:
let (x:seq<int>) =
[1..10]
|> Seq.map (fun t -> t + 1)
Edit: Please refer to recommended answer, as my answer is incomplete.
来源:https://stackoverflow.com/questions/45527979/which-defferences-seq-with-seq