Tech Off Post

Single Post Permalink

View Thread: LINQ Where; fold vs bind...
  • User profile image

    I was reading about how Aggregate is a 'fold' operation in functional programming terms.

    Aggregate 'folds' the resultset into a single return value, and it is not the same as a scalar function, from what I've been reading... Now what a 'right fold' really is I can't tell you...

    Another piece of information: Another possible explanation for [LINQ Aggregate] not being called fold is that fold generally implies a recursive operation. Linq is mostly implemented with iterators. This may be something of interest to you. There is no recursive 'fold' operation in LINQ, apparently, Aggregate simulates a fold but is implemented with iterators. Does this mean that you were looking for a true 'fold' operation for a purpose which LINQ is not able to support? I think you're too smart for me.


    This article is by Bart De Smet and is worth a look:

    Here's another nice article about folds in LINQ: