This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function curry(\Closure $f) { | |
$rf = new \ReflectionFunction($f); | |
$arity = $rf->getNumberOfParameters(); | |
function acc($f, $arity, $args=[]) { | |
return function(...$acc) use($f, $arity, $args) { | |
$acc = array_merge($args, $acc); | |
return (count($acc) >= $arity) ? $f(...$acc) : acc($f, $arity, $acc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function curry(\Closure $f) { | |
$rf = new \ReflectionFunction($f); | |
$arity = $rf->getNumberOfParameters(); | |
function acc($f, $arity, $args=[]) { | |
return function(...$acc) use($f, $arity, $args) { | |
$acc = array_merge($args, $acc); | |
return (count($acc) >= $arity) ? $f(...$acc) : acc($f, $arity, $acc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% https://en.wikipedia.org/wiki/Collatz_conjecture | |
-module(collatz). | |
-export([collatz/1]). | |
collatz(N) -> collatz(N,0,[N]). | |
collatz(1, C, Acc) -> {C, lists:reverse(Acc)}; | |
collatz(N, C, Acc) -> | |
R = case is_even(N) of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ErrorPreventer | |
{ | |
private static $squatter; | |
public static function init() | |
{ | |
static::$squatter = new \SplFixedArray(100000); | |
register_shutdown_function(array(__CLASS__, 'helpMe')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Domain | |
{ | |
protected $foo; | |
protected $bar; | |
protected $baz; | |
public function setFoo($foo) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Your\MainBundle; | |
use Symfony\Bundle\FrameworkBundle\Client; | |
use Symfony\Component\HttpKernel\HttpKernelInterface; | |
class ExceptionalClient extends Client | |
{ | |
static private $catchExceptions = true; |