Anonymous user
Vector products: Difference between revisions
Updated D code
(Updated D code) |
|||
Line 324:
=={{header|D}}==
<lang d>import std.stdio, std.algorithm, std.conv, std.numeric;
struct V3 {
Line 333:
pure nothrow double dot(in V3 rhs) const {
return
}
Line 354:
void main() {
const V3 a = {3
writeln("a
writeln("
writeln("
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>
Output:
<pre>a = [3, 4, 5
a .
a x
a . (b x c) = 6
a x (b x c) = [-267, 204, -3]</pre>
=={{header|Euphoria}}==
|