Created
March 17, 2014 11:23
-
-
Save karminski/9597621 to your computer and use it in GitHub Desktop.
currying.php
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 | |
define("_", 0); | |
class Currying{ | |
private $arg1; | |
public function __construct($arg1){ | |
$this->func_a[0] = $arg1; | |
$this->func_a[_] = function($arg2){ | |
return $this->func_a[0] + $arg2; | |
}; | |
} | |
} | |
$Currying = new Currying(1); | |
var_dump($Currying->func_a[_](2)); | |
print "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n"; | |
$currying = function($arg1){ | |
class Currying{ | |
private $arg1; | |
public function __construct($arg1){ | |
$this->arg1 = $arg1; | |
} | |
function func_b(){ | |
return function($arg2){ | |
return $this->arg1 + $arg2; | |
}; | |
} | |
} | |
$Currying = new Currying($arg1); | |
return $Currying->func_b(); | |
}; | |
$currying = $currying(1); | |
var_dump($currying(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment