Talk:Dot product: Difference between revisions
Content added Content deleted
m (Make voices distinguishable) |
|||
Line 45: | Line 45: | ||
// -> 3 |
// -> 3 |
||
})();</lang> -- --[[User:Hout|Hout]] ([[User talk:Hout|talk]]) 16:56, 27 February 2016 (UTC) |
|||
})();</lang> |
|||
I'd be inclined to say go for it. |
:I'd be inclined to say go for it. |
||
That said, I'd also be inclined to replace zipWith with something like: |
:That said, I'd also be inclined to replace zipWith with something like: |
||
<lang javascript> function zipWith(f, xs, ys) { |
:<lang javascript> function zipWith(f, xs, ys) { |
||
return xs.length === ys.length ? ( |
return xs.length === ys.length ? ( |
||
xs.map(function(x, i) {return f(x,ys[i])}) |
xs.map(function(x, i) {return f(x,ys[i])}) |
||
Line 57: | Line 57: | ||
}</lang> |
}</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. |
: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.) |
:(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) |
:And, thanks! --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 19:36, 27 February 2016 (UTC) |