Dot product: Difference between revisions

→‎{{header|Raku}}: create a subroutine
No edit summary
(→‎{{header|Raku}}: create a subroutine)
Line 2,717:
{{works with|Rakudo|2010.07}}
We use the square-bracket meta-operator to turn the infix operator <code>+</code> into a reducing list operator, and the guillemet meta-operator to vectorize the infix operator <code>*</code>. Length validation is automatic in this form.
<syntaxhighlight lang="raku" line>saysub infix:<·> { [+] (1, 3, -5)@^a »*« (4,@^b -2, -1);</syntaxhighlight>}
 
say (1, 3, 5)·(4, -2, 1);</syntaxhighlight>
 
=={{header|Rascal}}==
1,934

edits