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