简体   繁体   中英

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

In F#, what is the difference 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM