How do I Aggregate multiple IEnumerables of T

后端 未结 5 1790
春和景丽
春和景丽 2021-02-12 18:20

Given....

Public MasterList as IEnumerable(Of MasterItem)
Public Class MasterItem(Of T) 
    Public SubItems as IEnumerable(Of T)
End Class 

I

5条回答
  •  一个人的身影
    2021-02-12 18:48

    Enumerable.SelectMany is the key to the IEnumerable monad, just as its Haskell equivalent, concatMap, is the key to Haskell's list monad.

    As it turns out, your question goes right to the heart of a deep aspect of computer science.

    You will want to be careful with your phrasing, because Aggregate means something very different from SelectMany - even the opposite. Aggregate combines an IEnumerable of values into a single value (of possibly another type), while SelectMany uncombines an IEnumerable of values into even more values (of possibly another type).

提交回复
热议问题