In F#, what is the difference between functions "Seq.collect" and "Seq.map"? They seem equivalent from the description on MSDN.
+10
A:
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.
Dario
2010-01-24 13:20:48
Thanks, I should have looked at the function signatures more closely.
Manuel
2010-01-24 13:28:45
+9
A:
If you know LINQ, the following comparison may be useful:
F#: Seq.map
, LINQ: Select
F#: Seq.collect
, LINQ: SelectMany
cfern
2010-01-24 13:33:43
Thanks, your tip led me to this page which really helped:http://team.interknowlogy.com/blogs/danhanan/archive/2008/10/10/use-linq-s-selectmany-method-to-quot-flatten-quot-collections.aspx
Manuel
2010-01-24 13:49:00