상속: implements Widmogrod\FantasyLand\Pointed, implements Widmogrod\FantasyLand\Monoid, implements Widmogrod\FantasyLand\Setoid, implements Widmogrod\Common\ValueOfInterface, use trait Widmogrod\Common\PointedTrait, use trait Widmogrod\Common\ValueOfTrait
예제 #1
0
    public function test_it_should_filter_with_logs()
    {
        $data = [1, 10, 15, 20, 25];
        $filter = function ($i) {
            if ($i % 2 == 1) {
                return W::of(false, S::of("Reject odd number {$i}.\n"));
            } elseif ($i > 15) {
                return W::of(false, S::of("Reject {$i} because it is bigger than 15\n"));
            }
            return W::of(true);
        };
        list($result, $log) = f\filterM($filter, $data)->runWriter();
        $this->assertEquals([10], $result);
        $this->assertEquals('Reject odd number 1.
Reject odd number 15.
Reject 20 because it is bigger than 15
Reject odd number 25.
', $log->extract());
    }
예제 #2
0
 private function randomize()
 {
     return Stringg::of(md5(rand(0, 100)));
 }
예제 #3
0
 public static function of($value, FantasyLand\Monoid $side = null)
 {
     return new static($value, is_null($side) ? S::mempty() : $side);
 }