Comments (6)
Reported by @atifaziz on 2009-04-04 18:30:59
- Labels added: Type-Enhancement
- Labels removed: Type-Defect
from morelinq.
What about:
public static IEnumerable<TReturn> Infinity<TReturn>(TReturn start,
Func<TReturn, TReturn?> generator)
where TReturn : struct
{
generator.ThrowIfNull("generator");
TReturn? val = start;
while (val.HasValue)
{
yield return val.Value;
val = generator(val.Value);
}
}
public static IEnumerable<double> Noise(int seed)
{
Random r = new Random(seed);
return Infinity(r.NextDouble(), x => r.NextDouble());
}
Reported by bruno.ac.martins
on 2011-10-22 16:02:17
from morelinq.
mail me if you want the full implementation with testing
Reported by bruno.ac.martins
on 2011-10-22 17:17:39
from morelinq.
That's a pretty easy way of doing it, yes. Coming to think about it again after these years, maybe it's a bit odd to have an infinite enumerable? I haven't found other places in .NET where an enumerable sequence never end.
Reported by l.jarvensivu
on 2011-10-22 23:15:06
from morelinq.
There is already a Random
method, so I think this is already done.
from morelinq.
@fsateler Agree & thanks!
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`
- `Unfold` leaks state across iterations HOT 1
- Remove `Concat` that's been obsolete since 3.0 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.