Fwiw, “slide” sounds like a much more intuitive name than rotate, to me. 
Rotate sounds like a 2d matrix operation (often commonly done on lists). 
Additionally, we should probably support a range *or* an index as the 
second argument, since moving one thing is still useful, and would be a 
good first example in the docs.
On Saturday, September 4, 2021 at 2:04:31 PM UTC-4 José Valim wrote:

> Well, for a stream you are still traversing everything, then I guess it 
> makes sense to be linear. I guess the benefit is not having to allocate a 
> new data structure. Once again we will need two algorithms, depending if 
> the end is before or after start. If before, you need to accumulate until 
> you find the slice, then you emit the slice, emit the accumulator, and then 
> continue as usual. If after, you need to emit everything, until start, then 
> accumulate the slice, and emit everything as necessary. So both operations 
> will require you to buffer, the amount of buffered content depends on the 
> end position.
>
> On Sat, Sep 4, 2021 at 7:34 PM [email protected] <[email protected]> wrote:
>
>>
>>
>> On Saturday, September 4, 2021 at 7:21:45 PM UTC+2 José Valim wrote:
>>
>>> It could definitely be implemented as a Enum or a Stream function, but 
>>> the level of complexity is definitely much higher, and reduce would force 
>>> the implementation to be linear anyway. So I am honestly not sure if it is 
>>> worth it.
>>>
>>
>> The main part of the algorithm could be written using a couple of calls 
>> to `Enum(erable).slice`. In this case, at least as long as the number of 
>> elements to be moved is small, the implementation is faster than linear 
>> (for types that support faster than linear slicing).
>>
>> That is, until we concatenate the results at the end to form the rotated 
>> list. So at most it is an efficiency improvement of a constant factor, but 
>> the result will still be linear.
>>  Hmm... 
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elixir-lang-core/d54e1e48-a32c-4d9c-8307-d5cb7926050cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elixir-lang-core/d54e1e48-a32c-4d9c-8307-d5cb7926050cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/8903e169-dadc-48bf-98ea-f860f1bc0891n%40googlegroups.com.

Reply via email to