-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LongSequence
and LongRange
#815
Comments
If memory serves right, no one has asked for it before.
Since it's probably a very rare use case, wonder if it's even worth for you to go through the trouble of a PR and someone else having to maintain it. You could get away with using var longs = MoreEnumerable.Generate(1L, x => checked(x + 1)); In fact, you could get away with pretty thin wrappers: static class LongEnumerable
{
public static IEnumerable<long> Range(long from, long count) =>
Sequence(from, checked(from + count - 1), 1);
public static IEnumerable<long> Sequence(long from, long to, long step) =>
MoreEnumerable.Generate(from, x => checked(x + step))
.TakeWhile(x => x <= to);
} |
Yup, not sure about that either. Your wrappers are actually better than what I used before, so thanks. I don't know what's the triage process in this repo, how do you decide what to add to the API? My guess would be to leave this issue hanging and see if someone else needs this use case. |
Glad to hear they helped!
Nothing officially documented yet, but apart from one or two exceptions, the criteria that I've been using for a very long time now is that an extension/method has to do some non-trivial amount of work (and do it efficiently while maintaining correctness).
If you don't mind, I'll close it as we have enough open issues, people can search across closed issues and keeping it open doesn't prevent from duplicates getting opened anyway. If you do end up using |
Neither standard LINQ nor MoreLINQ have a way of generating a sequence of Int64s. I've noticed that because I actually needed such a method. Obviously generating a sequence from 1 to 10^18 would kill anything you'd run that on, however I have use cases where I have to generate sequences of reasonable length but of large values.
I would like the following methods added:
with obvious semantics identical to those of
Enumerable.Range
andMoreEnumerable.Sequence
but for Int64.If this was already considered but decided to not be implemented for MoreLINQ, let me know. If not I could implement a PR for these myself.
The text was updated successfully, but these errors were encountered: