Content deleted Content added
→Examples: Added javascript |
→Examples: Link languages |
||
Line 7:
===JavaScript===
[[JavaScript]] supports anonymous functions.
<source lang="javascript">
var foo = function(x) {return x*x;}
Line 16:
===Python===
[[Python (programming language)|Python]] supports anonymous functions through the lambda form. It is, however, expected to be only a single line of code and always returns whatever that line returns. For example:
<source lang="python">
foo = lambda x: x*x
Line 25:
===PHP===
[[PHP]] doesn't have true anonymous functions because the only way to reference functions is by name. The closest PHP is shown in the following.
<source lang="php">
$foo = create_function("$x", "return $x*$x;");
|