/** * This method tests the "dropWhile" method. * * @dataProvider data_dropWhile */ public function test_dropWhile(array $provided, array $expected) { $p0 = ILinkedList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type'); $p1 = $provided[1]; $r0 = ILinkedList\Module::dropWhile($p0, $p1); $e0 = $expected[0]; $this->assertInstanceOf('\\Saber\\Data\\ILinkedList\\Type', $r0); $this->assertSame($e0, $r0->unbox(1)); }
/** * This method returns a tuple where the first item contains longest prefix of the linked * list that satisfies 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 span(ILinkedList\Type $xs, callable $predicate) : ITuple\Type { return ITuple\Type::box2(ILinkedList\Module::takeWhile($xs, $predicate), ILinkedList\Module::dropWhile($xs, $predicate)); }