Esempio n. 1
0
 /**
  * This method returns a list of all numbers for the specified sequence.
  *
  * @access public
  * @static
  * @param IInteger\Type $x                                  where to start
  * @param Core\Type $y                                      either an integer representing
  *                                                          the end of the sequence or a
  *                                                          tuple describing the sequence
  * @return IArrayList\Type                                  an empty array list
  */
 public static function sequence(IInteger\Type $x, Core\Type $y) : IArrayList\Type
 {
     $buffer = array();
     if ($y instanceof ITuple\Type) {
         $s = IInteger\Module::subtract($y->first(), $x);
         $n = $y->second();
     } else {
         // ($y instanceof IInteger\Type)
         $s = IInteger\Type::one();
         $n = $y;
     }
     if (IInteger\Module::isNegative($s)->unbox()) {
         for ($i = $x; IInteger\Module::ge($i, $n)->unbox(); $i = IInteger\Module::add($i, $s)) {
             $buffer[] = $i;
         }
     } else {
         for ($i = $x; IInteger\Module::le($i, $n)->unbox(); $i = IInteger\Module::add($i, $s)) {
             $buffer[] = $i;
         }
     }
     return IArrayList\Type::box($buffer);
 }
Esempio n. 2
0
 /**
  * This method tests the "le" method.
  *
  * @dataProvider data_le
  */
 public function test_le(array $provided, array $expected)
 {
     $p0 = IInteger\Module::le(IInteger\Type::box($provided[0]), IInteger\Type::box($provided[1]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }