Skip to content

Instantly share code, notes, and snippets.

@karminski
Created March 17, 2014 11:23
Show Gist options
  • Save karminski/9597621 to your computer and use it in GitHub Desktop.
Save karminski/9597621 to your computer and use it in GitHub Desktop.
currying.php
<?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