Dot product: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring the hard way) |
Not a robot (talk | contribs) (Add BCPL) |
||
Line 451: | Line 451: | ||
{{Out}} |
{{Out}} |
||
<pre>3</pre> |
|||
=={{header|BCPL}}== |
|||
<lang bcpl>get "libhdr" |
|||
let dotproduct(A, B, len) = valof |
|||
$( let acc = 0 |
|||
for i=0 to len-1 do |
|||
acc := acc + A!i * B!i |
|||
resultis acc |
|||
$) |
|||
let start() be |
|||
$( let A = table 1, 3, -5 |
|||
let B = table 4, -2, -1 |
|||
writef("%N*N", dotproduct(A, B, 3)) |
|||
$)</lang> |
|||
{{out}} |
|||
<pre>3</pre> |
<pre>3</pre> |
||