3 ms·
create_function is not equivalent to a python lambda. It's just a function for creating other functions. The key thing with a lambda in python is that it is de
by TylerE 14y ago
create_function is not equivalent to a python lambda. It's just a function for creating other functions.
The key thing with a lambda in python is that it is defined at the usage site.
so you can do:
filter(lambda x: x > 42, mylist)
Whereas in php that would be:
$mylambda = create_function('$x','return $x > 42;');
filter($mylambda, $mylist);
Yes, the usage strings as code adds yet another level of WTF to this example.