/** * This method tests the "filter" method. * * @dataProvider data_filter */ public function test_filter(array $provided, array $expected) { $p0 = IArrayList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type'); $p1 = $provided[1]; $r0 = IArrayList\Module::filter($p0, $p1); $e0 = $expected[0]; $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $r0); $this->assertSame($e0, $r0->unbox(1)); }
/** * This method (aka "remove") returns an array list containing those items that do not * satisfy the predicate. Opposite of "filter". * * @access public * @static * @param IArrayList\Type $xs the array list * @param callable $predicate the predicate function to be used * @return IArrayList\Type an array list containing those items * that do not satisfy the predicate */ public static function reject(IArrayList\Type $xs, callable $predicate) : IArrayList\Type { return IArrayList\Module::filter($xs, function (Core\Type $x, IInt32\Type $i) use($predicate) : IBool\Type { return IBool\Module::not($predicate($x, $i)); }); }