Skip to content

Commit 409ebe3

Browse files
committed
fix dot
1 parent 3d62201 commit 409ebe3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Vector/Lib/Lambda.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected static function __pipe(...$fs)
2525

2626
protected static function __dot($f, $g)
2727
{
28-
return function($x) {
28+
return function ($x) use ($f, $g) {
2929
return $f($g($x));
3030
};
3131
}

tests/Lib/LambdaTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Vector\Core\Module;
66
use Vector\Lib\Lambda;
7+
use Vector\Lib\Math;
78

89
class LambdaTest extends \PHPUnit_Framework_TestCase
910
{
@@ -104,4 +105,11 @@ public function testFlip()
104105
$this->assertEquals(4, $subtract(2, 6)); // 6 - 2
105106
$this->assertEquals(-4, $flippedSubtract(2, 6)); // 2 - 6
106107
}
108+
109+
public function testDot()
110+
{
111+
$add2ThenAdd1 = Lambda::dot(Math::add(1), Math::add(2));
112+
113+
$this->assertEquals(3, $add2ThenAdd1(0));
114+
}
107115
}

0 commit comments

Comments
 (0)