Which defferences “Seq” with “seq” ?

≡放荡痞女 提交于 2019-12-23 12:15:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!