I was playing around with some F# code and thinking about lazy lists in Haskell and how I could get them in F#. Well, since I know how to make an enumerable function in C# I decided to have a go making one in that instead.
foreach (var i in LazyRange(1, (n) => ++n).Take(10))
var fizz = LazyRange(1, (n) => ++n)
.TakeWhile(n => n < 1000)
.Where(n => n % 3 == 0 || n % 5 == 0)
IEnumerable<T> LazyRange<T>(T start, Func<T, T> successor)
T value = start;
yield return value;
value = successor(value);
To use it supply a starting value and a function to provide each successive value. Use Take or TakeWhile to limit the collection otherwise you will end up with an infinite list.