Thank you for the proposal!
What jumps at me immediately is that the APIs are using integers to specify
positions in the collection. I think they should be using collection's
indices instead.
I'm unsure why we need `first` and `last` -- shouldn't the API operate on
the whole collection? We have slices to operate on subsequences.
It is interesting that you are proposing that the new algorithms should
produce lazy views. I agree this is consistent with the rest of the
library, but I'm worried about the performance implications. Have you
thought about this? One point to keep in mind is that you can implement
the `_copyToNativeArrayBuffer()` and `_initializeTo()` entry points in all
new lazy collections, using the optimal eager algorithm. This way,
converting them to arrays will be fast.
Another point to consider is how the call site of these functions looks
like:
collection.rotate(10, middle: 20, last: 30)
The first number hangs in the air, it is unclear what its meaning is.
Dmitri
···
On Mon, Dec 28, 2015 at 10:29 PM, Sergey Bolshedvorsky via swift-evolution < swift-evolution@swift.org> wrote:
Hi all,
I have created a PR with with a formal proposal for this feature:
Proposal for adding rotate algorithm similar to std::rotate() by bolshedvorsky · Pull Request #77 · apple/swift-evolution · GitHubWhat are your thoughts?
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/