Cartesian product of immutable ranges
matovitch
camille.brugel at laposte.net
Sun Jan 26 13:49:36 PST 2014
I posted a question on stackoverflow about the cartesian product
of immutable ranges :
http://stackoverflow.com/questions/21368501/cartesian-product-of-immutable-ranges
There are a lot of various thing I don't understand.
This code compiles and run :
import std.stdio;
import std.range;
import std.algorithm;
void main() {
immutable int[] B = [ 1, 2, 3 ];
int[] C = [ 4, 5, 6 ];
auto BC = cartesianProduct(B, C);
writeln(BC);
}
This one doesn't :
import std.stdio;
import std.range;
import std.algorithm;
void main() {
int[] B = [ 1, 2, 3 ];
immutable int[] C = [ 4, 5, 6 ];
auto BC = cartesianProduct(B, C);
writeln(BC);
}
And this one does :
import std.stdio;
import std.range;
import std.algorithm;
void main() {
immutable int[] B = [ 1, 2, 3 ];
immutable int[] C = [ 4, 5, 6 ];
auto BC = zip(B, C);
writeln(BC);
}
Here B and C aren't inputRange thought acording to the template
constraint of zip there should be. How can it compiles ? How to
compute the cartesian product of two immutable ranges ?
More information about the Digitalmars-d-learn
mailing list