Function definition: Difference between revisions
Content added Content deleted
Underscore (talk | contribs) (→{{header|Coco}}: Mentioned `it`.) |
(Added zkl) |
||
Line 1,746: | Line 1,746: | ||
<pre>> multiply(2, 4.5) |
<pre>> multiply(2, 4.5) |
||
9</pre> |
9</pre> |
||
=={{header|zkl}}== |
|||
<lang zkl>fcn multiply(x,y){x*y}</lang> |
|||
<lang zkl>fcn(x,y){x*y}(4.5,3) // --> 13.5</lang> |
|||
Since all functions are vararg:<lang zkl>fcn multiply{vm.arglist.reduce('*)} |
|||
multiply(1,2,3,4,5) //--> 120</lang> |
|||
Operators are first class objects so:<lang zkl>var mul=Op("*"); mul(4,5) //-->20</lang> |
|||
=={{header|ZX Spectrum Basic}}== |
=={{header|ZX Spectrum Basic}}== |
||
On the ZX Spectrum, function names are limited to one letter. Note that the function becomes effective as soon as it is entered into the program, and does not need to be run |
On the ZX Spectrum, function names are limited to one letter. Note that the function becomes effective as soon as it is entered into the program, and does not need to be run |