Cartesian product of immutable ranges

matovitch camille.brugel at laposte.net
Sun Jan 26 15:25:26 PST 2014


On Sunday, 26 January 2014 at 22:19:47 UTC, Stanislav Blinov 
wrote:
> On Sunday, 26 January 2014 at 21:49:37 UTC, matovitch wrote:
>
> Short answer: with std.algorithm - you can't. Because internally
> it (Zip, actually) performs assignments, and you can't assign to
> immutable(T).
>
> Why?

Here is the problem...

import std.stdio;
import std.range;
import std.algorithm;

void main() {
     writeln(zip([1,2,4,3], take(Repeat!(immutable(int))(2), 4)));
}

With the current implementation the second order immutable should 
be stripped...


More information about the Digitalmars-d-learn mailing list