Lambda Function in php

Lambda function became very popular in Python. And from version 4.0.1, we have it on php as well.

Here’s a little snippet for your copy-paste comfort :

<?php
$newfunc 
create_function(‘$a,$b’‘return ”ln($a) + ln($b) = ” . log($a * $b);’);
echo 
“Lambda Function: $newfunc\n”;
echo 
$newfunc(2M_E) . “\n”;?>

 

Give it a try on php-cli to check out J

This entry was posted in Blog Post and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">