Given....
Public MasterList as IEnumerable(Of MasterItem)
Public Class MasterItem(Of T)
Public SubItems as IEnumerable(Of T)
End Class
I
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).