Function definition: Difference between revisions
Content deleted Content added
Add SmallBASIC |
Add YAMLScript sample |
||
Line 3,697: | Line 3,697: | ||
<syntaxhighlight lang="xslt">{mf:multiply(2,3)} |
<syntaxhighlight lang="xslt">{mf:multiply(2,3)} |
||
<xsl:value-of select="mf:multiply(2,3)" /></syntaxhighlight> |
<xsl:value-of select="mf:multiply(2,3)" /></syntaxhighlight> |
||
=={{header|YAMLScript}}== |
|||
<syntaxhighlight lang="yaml"> |
|||
!yamlscript/v0 |
|||
# Main function definition with variable arguments: |
|||
defn main(& args): |
|||
answer =: |
|||
multiply: ARGS* |
|||
say: "multiply($(ARGS.join(', '))) = $answer" |
|||
# A multi-arity function definition: |
|||
defn multiply: |
|||
(): 1 |
|||
(x): x |
|||
(x y): x * y |
|||
(x y & more): |
|||
reduce multiply: multiply(x y) more |
|||
</syntaxhighlight> |
|||
=={{header|Yorick}}== |
=={{header|Yorick}}== |