Beispiel #1
0
 /**
  * This method tests the "span" method.
  *
  * @dataProvider data_span
  */
 public function test_span(array $provided, array $expected)
 {
     $p0 = ILinkedList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type');
     $p1 = $provided[1];
     $e0 = $expected[0];
     $e1 = $expected[1];
     $r0 = ILinkedList\Module::span($p0, $p1);
     $this->assertInstanceOf('\\Saber\\Data\\ITuple\\Type', $r0);
     $v0 = $r0->first();
     $v1 = $r0->second();
     $this->assertInstanceOf('\\Saber\\Data\\ILinkedList\\Type', $v0);
     $this->assertSame($e0, $v0->unbox(1));
     $this->assertInstanceOf('\\Saber\\Data\\ILinkedList\\Type', $v1);
     $this->assertSame($e1, $v1->unbox(1));
 }
Beispiel #2
0
 /**
  * This method returns a tuple where the first item contains longest prefix of the linked
  * list that does not satisfy the predicate and the second item contains the remainder.
  *
  * @access public
  * @static
  * @param ILinkedList\Type $xs                              the linked list
  * @param callable $predicate                               the predicate function to be used
  * @return ITuple\Type                                      the tuple
  */
 public static function break_(ILinkedList\Type $xs, callable $predicate) : ITuple\Type
 {
     return ILinkedList\Module::span($xs, function (Core\Type $x, IInt32\Type $i) use($predicate) : IBool\Type {
         return IBool\Module::not($predicate($x, $i));
     });
 }