diff --git a/m/generate.md b/m/generate.md index 164fc5c..3a0a470 100644 --- a/m/generate.md +++ b/m/generate.md @@ -3,7 +3,15 @@ Returns a sequence of values consecutively generated by a generator function ```c# --destination-file ../code/Program.cs --region statements --project ../code/TryMoreLinq.csproj -// TODO add example +// Generate a range of Int64 values. +public static IEnumerable LongRange(long from, long count) => + MoreEnumerable.Generate(from, x => x + 1) + .TakeWhile(x => x <= checked(from - 1 + count)); + +// Generate an arithmetic sequence of Int64 values up to a given value. +public static IEnumerable LongSequence(long from, long to, long step) => + MoreEnumerable.Generate(from, x => checked(x + step)) + .TakeWhile(x => x <= to); ``` For more details, [see the documentation][doc].