Vector products: Difference between revisions

Content added Content deleted
m (made Wikipedia references more uniform.)
(→‎JS ES6: Tidied and extended test.)
Line 1,884: Line 1,884:


console.log(unlines(
console.log(unlines(
zipWith(
zipWith(k => f => k + show(
k => f => k + show(
fapp(f)([a, b, c])
fapp(f)([a, b, c])
))(['a . b', 'a x b', 'a . (b x c)', 'a x (b x c)'])(
)
)(['a . b', 'a x b', 'a . (b x c)', 'a x (b x c)'])(
[dotProduct, crossProduct, scalarTriple, vectorTriple]
[dotProduct, crossProduct, scalarTriple, vectorTriple]
)
)
.concat([
'a . d' + show(
dotProduct(a)(d)
),
'a . (b x d)' + show(
scalarTriple(a)(b)(d)
)
])
));
));
console.log(
'a . d' + show(
dotProduct(a)(d)
)
)
};
};


Line 1,974: Line 1,975:
a . (b x c) = 6
a . (b x c) = 6
a x (b x c) = [-267,204,-3]
a x (b x c) = [-267,204,-3]
a . d => Dot product not defined - vectors differ in dimension</pre>
a . d => Dot product not defined - vectors differ in dimension.
a . (b x d) => crossProduct is defined only for 3d vectors.</pre>


=={{header|jq}}==
=={{header|jq}}==