[英]Difference between Seq.map and Seq.collect in F#
In F#, what is the difference between functions "Seq.collect" and "Seq.map"? 在F#中,函数“Seq.collect”和“Seq.map”之间有什么区别? They seem equivalent from the description on MSDN.
它们似乎与MSDN上的描述相同。
If you know LINQ, the following comparison may be useful: 如果您了解LINQ,则以下比较可能有用:
F#: Seq.map
, LINQ: Select
F#:
Seq.map
,LINQ: Select
F#: Seq.collect
, LINQ: SelectMany
F#:
Seq.collect
,LINQ: SelectMany
Seq.collect
will first map each sequence element to a new sequence and flatten this sequences into a single one. Seq.collect
将首先将每个序列元素映射到一个新序列,并将这些序列展平为一个序列。
Seq.map
will just map each element to a new element . Seq.map
只会将每个元素映射到一个新元素 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.