What use is lambda in PHP?

后端 未结 5 1707
南方客
南方客 2020-12-12 21:40

The lambda anonymous function is part of PHP 5.3. What use does it have? Is there anything that one can only do with lambda? Is lambda better for certain tasks?

I\'

5条回答
  •  囚心锁ツ
    2020-12-12 22:30

    The implementation of the cryptic Y combinator?

    function Y($F)
    {
      $func = function ($f) { return $f($f); };
    
      return $func(function ($f) use($F)
      {
        return $F(function ($x) use($f)
        {
          $ff = $f($f);
    
          return $ff($x);
        });
      });
    }
    

    Cited Source: http://fabien.potencier.org/article/17/on-php-5-3-lambda-functions-and-closures

提交回复
热议问题