Lambda-function generator

3.0.1 2021-07-03 15:10 UTC

This package is not auto-updated.

Last update: 2024-05-05 04:45:17 UTC


README

Build Status Coverage Status StyleCI

Generates lambda function using given string pattern.

Example

use function Lambda\l;

// Unindexed placeholders mode
$sum = l('$ + $');

echo $sum(2, 4); // will output 6


// Indexed placeholders mode
$func = l('$0 + ($0 * $1)');

echo $func(2, 6); // will output 14


// Filtering function
$numbers = range(1, 10);

$evens = array_filter(l('$ % 2 == 0'), $numbers); // will produce array [2, 4, 6, 8, 10]