Comments (7)
About to delete my previous comment, which was unnecessarily wordy...
A few notes...
-
There is a concept from functional programming called an "unfold", which is the projection of a single entity into a collection via a repeated or recursive operation. Our
Generate
method in its current form is a special case of the "unfold" operation. It supports value-based unfolding well, but when you start working with more complex objects, usability breaks down. -
An "unfold" on complex objects is much more of a graph transformation operation than a querying/filtering operation. So far, LINQ itself as well as MoreLinq have been focused on querying and filtering. It may be that the more general "unfold" is useful, but more appropriately bundled with similar functionality. FWIW, I would argue that querying/filtering is a special case of graph transformation, and a querying/filtering DSL (even up to and including SQL itself) could benefit greatly from access to more general graph transformation operations. But MoreLinq may not be the place to start providing this.
-
The
Generate
name pairs up well with its inverse operation provided in the .NET Framework v3.5:Aggregate
. Were we working in a functional environment rather than procedural, these would probably be calledUnfold
andFold
, respectively. But since we can't changeAggregate
, I'm in favor of keeping theGenerate
name or something similarly untuitively connected toAggregate
.
Reported by @cammerman on 2009-03-10 23:49:42
from morelinq.
No problem. I only just noticed Jared Parson has put together a lot of his excellent work on
functional/immutable coding as a library called BclExtras on the MSDN code gallery. It has a lot of interesting stuff and looks a little closer to what I was looking for - it sounds like you have a specific plan for what MoreLinq will cover.
Reported by daniel.earwicker
on 2009-03-21 09:54:42
from morelinq.
Reported by @atifaziz on 2009-04-04 19:28:51
- Labels added: Type-Enhancement
- Labels removed: Type-Defect
from morelinq.
As already mentioned by CAmmerman, unfold
function can solve it;
Exception innermost = Unfold(caught, e => e.InnerException != null ? Tuple.Create(e, e.InnerException) : null).Last();
from morelinq.
@atifaziz will you close this issue now that unfold
were implemented ?
from morelinq.
@leandromoh Yep & thanks for helping & remembering to triage this.
from morelinq.
In the final form Unfold
was released in 2.3, the example of traversing nested exceptions to find the innermost will look like this:
var innermost =
MoreEnumerable.Unfold(caught, e => e, e => e != null, e => e.InnerException, e => e)
.Last();
from morelinq.
Related Issues (20)
- FullGroupJoin with null keys HOT 1
- Suggestion: WithIndex<T> Extension Method to facilitate enumerating with an item and index tuple HOT 1
- Compile Error MoreLinq/ToDataTable.cs HOT 2
- Hide `ToDictionary()` in net8+
- Remove `Windowed` that's been obsolete since 3.0
- Add `Minima` & `Maxima` to supersede `MinBy` & `MaxBy`
- Hide `CountBy` in net9+
- Review NUnit1030
- Review NUnit1029
- `Pad` should throw `ArgumentOutOfRangeException` for invalid width
- `PadStart` should to throw `ArgumentOutOfRangeException` for invalid width
- `Interleave` shouldn't validate `otherSequences` members
- Improve GroupAdjacent HOT 9
- Remove tail items while condition is true
- Revise tests to avoid using `Eumerable.Range` HOT 4
- `Subsets` enumerator doesn't return same array from `Current`
- `Merge` masks original exception with an `ArgumentException` about no tasks
- Async versions of OrderedMerge and GroupAdjacent HOT 3
- Default elements from a secondary source HOT 2
- `FillForward` bug when filler is `null` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morelinq.