Vector products: Difference between revisions

Updated D entry
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
(Updated D entry)
Line 427:
<lang d>import std.stdio, std.conv, std.numeric;
 
immutable struct V3 {
union {
static immutable static struct { double x, y, z; }
immutable double[3] v;
}
Line 449:
/*@safe*/ pure nothrow {
return a.dot(b.cross(c));
// function vector_products.V3.cross (const(V3) rhs) immutable
// is not callable using argument types (const(V3)) const
}
 
Line 464 ⟶ 466:
writeln("a . b = ", a.dot(b));
writeln("a x b = ", a.cross(b));
writeln("a . (b x c) = ", scalarTriple(a, b, c));
writeln("a x (b x c) = ", vectorTriple(a, b, c));
}</lang>
{{out}}
Output:
<pre>a = [3, 4, 5]
b = [4, 3, 5]