コード例 #1
0
ファイル: pramda.php プロジェクト: kapolos/pramda
 public function testCurryN()
 {
     $sum2 = function ($a, $b) {
         return $a + $b;
     };
     $curriedSum2 = P::curryN(2, $sum2);
     $addToFive = $curriedSum2(5);
     $this->assertEquals(8, $addToFive(3));
     $this->assertEquals(8, $curriedSum2(3, 5));
     $sum3 = function ($a, $b, $c) {
         return $a + $b + $c;
     };
     $curriedSum3 = P::curryN(3, $sum3);
     $plus5 = $curriedSum3(5);
     $plus10 = $plus5(10);
     $minus4 = $plus10(-4);
     $this->assertEquals(11, $minus4);
     $this->assertEquals(11, $plus5(10, -4));
 }