Talk:Dot product: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 46: | Line 46: | ||
// -> 3 |
// -> 3 |
||
})();</lang> |
})();</lang> |
||
I'd be inclined to say go for it. |
|||
That said, I'd also be inclined to replace zipWith with something like: |
|||
<lang javascript> function zipWith(f, xs, ys) { |
|||
return xs.length === ys.length ? ( |
|||
xs.map(function(x, i) {return f(x,ys[i])}) |
|||
) : undefined; |
|||
}</lang> |
|||
Or, if you feel like <code>zipWith</code> should work with mis-matched argument lengths, give this implementation some other name. ... There is some use for the mismatched approach, but most of the time - including this example - that's just an error. |
|||
(I am not really fond of javascript's implementation of .map(), but this kind of thing is what it was designed for.) |
|||
And, thanks! --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 19:36, 27 February 2016 (UTC) |