Function definition: Difference between revisions

added MiniScript example
(added MiniScript example)
Line 1,757:
<code>'*</code> is syntax sugar for <code>(*)</code>, which is an anonymous function that takes two numbers from the data stack, multiplies them, and leaves the result on the data stack. To give it a name, we can use the <code>:</code> sigil which is syntax sugar for <code>define</code>.
<lang min>'* :multiply</lang>
 
=={header|MiniScript}}==
<lang MiniScript>multiply = function(x,y)
return x*y
end function
 
print multiply(6, 7)</lang>
{{out}}
<pre>42</pre>
 
=={{header|МiniZinc}}==
222

edits