Function definition: Difference between revisions
m
no edit summary
(→{{header|BASIC}}: Added ANSI BASIC.) |
LalaithMeren (talk | contribs) mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1,219:
return a*b;
}</syntaxhighlight>
=={{header|Chapel}}==
<syntaxhighlight lang="text">
proc multiply(a, b)
{
return a * b;
}
Can require that the two arguments be of the same type.
<syntaxhighlight lang="text">
proc multiply(a : ?t ... 2)
{
return a(0) * a(1)
}
</syntaxhighlight>
Will work on any type where the * operator is defined.
=={{header|ChucK}}==
Line 2,190 ⟶ 2,209:
Parameters are defined within parentheses after the fn token. To specify no parameters, use an empty set of parentheses.
<syntaxhighlight lang="langur">val .multiply = fn(.x, .y) { .x * .y }
▲.multiply(3, 4)</syntaxhighlight>
.multiply(3, 4)</syntaxhighlight>
|