-
Notifications
You must be signed in to change notification settings - Fork 440
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
CombinationsSequence
should be a Collection
#219
Comments
@dabrahams Could you give some examples of the limitations that you're running into here? IIRC, the reason that That said, let numbers = [10, 20, 30, 40, 50]
for x in numbers.indexed(by: [4, 2, 0]) {
print(x)
}
// 50
// 30
// 10 |
I didn't run into a limitation, but I know such limitations exist. It's the whole reason I wrote Zip2Collection: there are algorithms that are defined only on
That's no reason it can't be a collection, as you yourself know well and this implementation demonstrates.
I don't know what your N is in this case; it's certainly not the length of the resulting collection, which is what people usually mean when they say O(N). The work of dereferencing this thing is proportional to the data footprint of the elements you get, which is no worse than "It's surprisingly expensive" is subjective and not a reason for non-conformance to a protocol. The implementation either meets the efficiency bounds (and we even play loosey-goosey with that criterion in places) or it does not. |
It's multipass (like almost every other
Sequence
in practice). Not being a collection limits its applicability in silly ways.The text was updated successfully, but these errors were encountered: