Jump to content

Dot product: Difference between revisions

no edit summary
m (→‎{{header|Picat}}: Added {{out}})
No edit summary
Line 3,188:
{{out}}
<pre>3</pre>
 
=={{header|Vlang}}==
<lang vlang>fn dot(x []int, y []int) ?int {
if x.len != y.len {
return error("incompatible lengths")
}
mut r := 0
for i, xi in x {
r += xi * y[i]
}
return r
}
fn main() {
d := dot([1, 3, -5], [4, -2, -1])?
 
println(d)
}</lang>
 
{{out}}
<pre>
3
</pre>
 
=={{header|Wart}}==
338

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.