akanehara/ginq

Add support for expressions

hason opened this issue · 5 comments

It would be amazing to add a shorthand notation for closures:

$xs = Ginq::from(array(1,2,3))->where('x % 2 != 0')->select('x * x');

and/or

$xs = Ginq::from(array(1,2,3))
         ->where(['x' => 'x % 2 != 0'])->select(['v, k' => 'k+v']);

See

👍

Added support for free variables.

['x'=>'x + y', 'y'=>$y]

means

function ($x) use ($y) { return $x + $y; }

Added short lambda wrapper.

$y = 99;
$f = Ginq::fun(['x'=>'x + y', 'y'=>$y]);
echo $f(1);
100