Call($item); return new ArrayIterator($result); } /** * @static * @param Iterator $iterator * @return array */ public static function ToArray(Iterator $iterator) { $result = array(); foreach($iterator as $value) $result[] = $value; return $result; } public static function L($lambda) { list($params, $code) = explode('=>', $lambda, 2); $params = rtrim($params, ') '); $params = ltrim($params, '( '); if (func_num_args() > 1) { $outParams = array(); for($i = 1; $i < func_num_args(); $i++) { $outParams[] = func_get_arg($i); if ($params != '') $params .= ','; $params .= '$_' . $i; } return new Lambda($outParams, create_function($params, 'return ' . $code . ';')); } return create_function($params, 'return ' . $code . ';'); } } interface ISMCallable { function Call(); } class Lambda implements ISMCallable { private $outParams; private $function; public function __construct($outParams, $function) { $this->outParams = $outParams; $this->function = $function; } public function Call() { $closureArgs = func_get_args(); return call_user_func_array($this->function, array_merge($closureArgs, $this->outParams)); } } ?>