Dot product: Difference between revisions
m
→JS ES6
m (→JS ES6: Tidied) |
m (→JS ES6) |
||
Line 1,590:
===ES6===
Composing functional primitives into a '''dotProduct()''' which returns a '''
<syntaxhighlight lang="javascript">(() => {
Line 1,597:
// ------------------- DOT PRODUCT -------------------
// dotProduct :: [Num] -> [Num] -> Either Null Num
const dotProduct = xs =>
ys => xs.length === ys.length
? sum(zipWith(mul)(xs)(ys))
:
|