Esempio n. 1
0
 /**
  * This method tests the "foldLeft" method.
  *
  * @dataProvider data_foldLeft
  */
 public function test_foldLeft(array $provided, array $expected)
 {
     $p0 = IArrayList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type');
     $p1 = $provided[1];
     $r0 = IArrayList\Module::foldLeft($p0, $p1, IInt32\Type::zero());
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $r0);
     $this->assertSame($e0, $r0->unbox());
 }
Esempio n. 2
0
 /**
  * This method returns the collection as a linked list.
  *
  * @access public
  * @static
  * @param IArrayList\Type $xs                               the operand
  * @return ILinkedList\Type                                 the collection as a linked list
  */
 public static function toLinkedList(IArrayList\Type $xs) : ILinkedList\Type
 {
     return IArrayList\Module::foldLeft($xs, function (ILinkedList\Type $c, Core\Type $x) {
         return ILinkedList\Module::append($c, $x);
     }, ILinkedList\Type::empty_());
 }