开发者

Difference between Seq.map and Seq.collect in F#

开发者 https://www.devze.com 2022-12-17 18:51 出处:网络
In F#, what is the diffe开发者_C百科rence between functions \"Seq.collect\" and \"Seq.map\"? They seem equivalent from the description on MSDN.If you know LINQ, the following comparison may be useful:

In F#, what is the diffe开发者_C百科rence between functions "Seq.collect" and "Seq.map"? They seem equivalent from the description on MSDN.


If you know LINQ, the following comparison may be useful:

F#: Seq.map, LINQ: Select

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.map will just map each element to a new element.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号