Comment #0 by bearophile_hugs — 2012-08-25T19:02:50Z
import std.math;
void main() {
double[3] a = [1.0, 2.0, 3.0];
double[3] b = a[] ^^ 3; // OK
double[3] c = [10.0, 20.0, 30.0];
double[3] d;
d = (a[] - c[]) ^^ 3; // error
}
DMD 2.061alpha gives:
test.d(7): Error: incompatible types for ((a[] - c[]) ^^ (cast(double)3)): 'double[]' and 'double'
While this shows a problem even with the first form:
import std.math;
void foo(T)(T[] arr) {}
void main() {
double[3] a = [1.0, 2.0, 3.0];
foo(a[] ^^ 3);
}
test.d(5): Error: Array operation a[] ^^ 3L not implemented
Someday in D I'd like to be able compute a distance like this:
((v1[] - v2[]) ^^ 2).sum().sqrt();
Comment #1 by bearophile_hugs — 2013-06-08T15:09:56Z
Sorry, a dupe of mine...
*** This issue has been marked as a duplicate of issue 10306 ***