Re: understanding lambda



On Jun 16, 3:52 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
lawpoop wrote:
Trying to wrap my head around the lambda concept.

I saw this example on the php website:

$func = function($value) { return $value * 2; };
print_r(array_map($func, range(1, 5)));

Which led me to conclude this definition

"A lambda function is a function whose name is a variable, rather than
a hard-coded string."

Is this correct?

Not quite.  A lambda function is one you create on the fly, as in your
first statement.  The function doesn't have to be created on the fly to
be callable via a variable (your second statement).

Thanks, Jerry.

Can you give a more formal definition of "created on the fly" ?

If I write

function test_function() {
return ;
}

Why wouldn't ( or would ) that be "created on the fly"?

What are other ways you can call a function via a variable?
.



Relevant Pages

  • Re: boolean localization problem
    ... (snipped discussion about rendering values to string by WScript.Echo and Msgbox) ... vbCrLf & _ ... Output of the first statement is the same wrong output whether Result and Expected are the same or different or even undefinded. ...
    (microsoft.public.scripting.vbscript)
  • Re: SQL statements
    ... | Can anyone explain why when I run the first statement in Oracle XE I ... '18-jun-07' is not a date it is a string. ... Michel Cadot ...
    (comp.databases.oracle.misc)
  • Interpolation question
    ... Any one have an idea why this first statement works just fine.... ... Use of uninitialized value in concatenation or string at...... ... Many thansk in advance... ...
    (comp.lang.perl.misc)
  • Re: understanding lambda
    ... lawpoop wrote: ... I saw this example on the php website: ... A lambda function is one you create on the fly, as in your first statement. ...
    (alt.php)