Vector products: Difference between revisions

Content added Content deleted
(Added Haskell)
m (→‎{{header|Haskell}}: removed some empty lines)
Line 471: Line 471:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>
<lang haskell>type Vector a = [a]
type Vector a = [a]
type Scalar a = a
type Scalar a = a


Line 503: Line 502:
, "a . b x c = " ++ (show $ scalarTriple a b c)
, "a . b x c = " ++ (show $ scalarTriple a b c)
, "a x b x c = " ++ (show $ vectorTriple a b c)
, "a x b x c = " ++ (show $ vectorTriple a b c)
, "a . d = " ++ (show $ dot a d) ]
, "a . d = " ++ (show $ dot a d) ]</lang>
Output:<pre>
</lang>
Output:
<pre>
a . b = 49
a . b = 49
a x b = [5,5,-7]
a x b = [5,5,-7]
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 = *** Exception: Dotted Vectors must be of equal dimension.
a . d = *** Exception: Dotted Vectors must be of equal dimension.</pre>
</pre>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==