PHP code example of phrenotype / lambda

1. Go to this page and download the library: Download phrenotype/lambda library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phrenotype / lambda example snippets


$add = lambda(function($a, $b, $c){
	return $a + $b + $c;
});

echo $add(4,5,2);
echo $add(4,5)(2);
echo $add(4)(5,2);
echo $add(4)(5)(2);

$add = lambda(function($a, $b, $c=2){
	return $a + $b + $c;
});

echo $add(4,5,2); // Ok
echo $add(4)(5,2) // Ok
echo $add(4,5)(2); // Error
echo $add(4)(5)(2); //Error