On 5/20/23 04:21, kdevel wrote:
> Thanks for your explications!
> On Friday, 19 May 2023 at 21:18:28 UTC, Ali Çehreli wrote:
>> [...]
>> - std.range.zip can be used instead but it does not provide 'ref'
>> access to its elements.
> How/why does sort [1] work with zipped arrays?

I don't know but wholesale assignment to zip's elements do transfer the effect, which sort does while swapping elements. However, copies of those range elements do not carry that effect:

import std;

void main() {
    auto a = [ 0, 1 ];
    auto z = zip(a);
    z[0] = z[1];
    writeln("worked: ", a);

    zip(a).each!(e => e = 42);
    writeln("  nope: ", a);

And each does not take (ref e) as a parameter at least in that  use case.

>> The following amap example there may be useful for your case but I
>> could not make the types work:
> Do you mean using the function pointer does not work?

I simply copied the example code bet there were mismatches between float, real, etc.

And I've just discovered something. Which one of the following is the expected documentation?



What paths did I take to get to those? I hope I will soon be motivated enough to fix such quality issues.


Reply via email to