Dot product: Difference between revisions

Content added Content deleted
(C++ alternative using std::inner_product)
(Added Arturo implementation)
Line 325: Line 325:
{{Out}}
{{Out}}
<lang AppleScript>3</lang>
<lang AppleScript>3</lang>

=={{header|Arturo}}==

<lang rebol>dotProduct: function [a,b][
[ensure equal? size a size b]

result: 0
loop 0..(size a)-1 'i [
result: result + (a \ i) * (b \ i)
]
return result
]

print dotProduct @[1, 3, neg 5] @[4, neg 2, neg 1]
print dotProduct [1 2 3] [4 5 6]</lang>

{{out}}

<pre>3
32</pre>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==