예제 #1
0
 /**
  * This method provides the data for testing the "span" method.
  *
  * @return array
  */
 public function data_span()
 {
     $predicate = function (Core\Boxable\Type $x, IInt32\Type $i) : IBool\Type {
         return IBool\Type::box($x->unbox() < 3);
     };
     $data = array(array(array(array(), $predicate), array(array(), array())), array(array(array(1), $predicate), array(array(1), array())), array(array(array(1, 2), $predicate), array(array(1, 2), array())), array(array(array(1, 2, 3), $predicate), array(array(1, 2), array(3))), array(array(array(1, 2, 3, 4), $predicate), array(array(1, 2), array(3, 4))), array(array(array(1, 3, 2, 4), $predicate), array(array(1), array(3, 2, 4))), array(array(array(3, 1, 4, 2), $predicate), array(array(), array(3, 1, 4, 2))));
     return $data;
 }
예제 #2
0
 /**
  * This method causes the iterator to advance to the next object.
  *
  * @access public
  * @final
  * @return IBool\Type                                       whether there are more objects
  */
 public final function next() : IBool\Type
 {
     $this->iterator->next();
     return IBool\Type::box($this->valid());
 }
예제 #3
0
 /**
  * This method evaluates whether the left operand is less than the right operand.
  *
  * @access public
  * @static
  * @param Throwable\Runtime\Exception $x                    the left operand
  * @param Throwable\Runtime\Exception $y                    the right operand
  * @return IBool\Type                                        whether the left operand is less than
  *                                                          the right operand
  */
 public static function lt(Throwable\Runtime\Exception $x, Throwable\Runtime\Exception $y)
 {
     // <
     return IBool\Type::box(Throwable\Runtime\Exception\Module::compare($x, $y)->unbox() < 0);
 }
예제 #4
0
 /**
  * This method evaluates whether the left operand is less than the right operand.
  *
  * @access public
  * @static
  * @param IOption\Type $xs                                  the left operand
  * @param IOption\Type $ys                                  the right operand
  * @return IBool\Type                                       whether the left operand is less than
  *                                                          the right operand
  */
 public static function lt(IOption\Type $xs, IOption\Type $ys) : IBool\Type
 {
     // <
     return IBool\Type::box(IOption\Module::compare($xs, $ys)->unbox() < 0);
 }
예제 #5
0
 /**
  * This method evaluates whether the operand is an odd number.
  *
  * @access public
  * @static
  * @param IInt32\Type $x                                    the object to be evaluated
  * @return IBool\Type                                       whether the operand is an odd
  *                                                          number
  */
 public static function isOdd(IInt32\Type $x) : IBool\Type
 {
     return IBool\Type::box($x->unbox() % 2 != 0);
 }
예제 #6
0
 /**
  * This method (aka "null") returns whether this list is empty.
  *
  * @access public
  * @final
  * @return IBool\Type                                       whether the list is empty
  */
 public final function isEmpty() : IBool\Type
 {
     return IBool\Type::box($this->__isEmpty());
 }
예제 #7
0
 /**
  * This method evaluates whether the operand is an odd number.
  *
  * @access public
  * @static
  * @param IInteger\Type $x                                  the object to be evaluated
  * @return IBool\Type                                       whether the operand is an odd
  *                                                          number
  */
 public static function isOdd(IInteger\Type $x) : IBool\Type
 {
     return IBool\Type::box(gmp_strval(gmp_div_r($x->unbox(), '2')) != '0');
 }
예제 #8
0
 /**
  * This method tests the "toString" method.
  *
  * @dataProvider data_toString
  */
 public function test_toString(array $provided, array $expected)
 {
     $p0 = IBool\Type::box($provided[0])->toString();
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IString\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }
예제 #9
0
 /**
  * This method (aka "exists" or "some") returns whether some of the items in the collection
  * passed the truthy test.
  *
  * @access public
  * @final
  * @param callable $predicate                               the predicate function to be used
  * @return IBool\Type                                       whether some of the items
  *                                                          passed the truthy test
  */
 public final function any(callable $predicate) : IBool\Type
 {
     return IBool\Type::box($this->either->__isLeft() && $predicate($this->either->item(), IInt32\Type::zero())->unbox());
 }
예제 #10
0
 /**
  * This method causes the choice block to be closed and executed.
  *
  * @access public
  * @final
  * @return IBool\Type                                       whether a clause has executed
  */
 public final function end() : IBool\Type
 {
     return IBool\Type::box($this->__end());
 }
예제 #11
0
 /**
  * This method returns whether the operand is a negative number.
  *
  * @access public
  * @static
  * @param IFloat\Type $x                                    the object to be evaluated
  * @return IBool\Type                                       whether the operand is a negative
  *                                                          number
  */
 public static function isNegative(IFloat\Type $x) : IBool\Type
 {
     return IBool\Type::box($x->unbox() < 0.0);
 }
예제 #12
0
 /**
  * This method returns whether the operand is a negative number.
  *
  * @access public
  * @static
  * @param IRatio\Type $x                                    the object to be evaluated
  * @return IBool\Type                                       whether the operand is a negative
  *                                                          number
  */
 public static function isNegative(IRatio\Type $x) : IBool\Type
 {
     $a = IInt32\Module::isNegative($x->numerator())->unbox();
     $b = IInt32\Module::isNegative($x->denominator())->unbox();
     return IBool\Type::box(($a || $b) && $a != $b);
 }
예제 #13
0
 /**
  * This method returns whether this instance is a "some" option.
  *
  * @access public
  * @final
  * @return IBool\Type                                       whether this instance is a "some"
  *                                                          option
  */
 public final function isDefined() : IBool\Type
 {
     return IBool\Type::box($this->__isDefined());
 }
예제 #14
0
 /**
  * This method causes the iterator to advance to the next object.
  *
  * @access public
  * @final
  * @return IBool\Type                                       whether there are more objects
  */
 public final function next() : IBool\Type
 {
     $this->i = IInt32\Module::increment($this->i);
     return IBool\Type::box($this->valid());
 }
예제 #15
0
 /**
  * This method returns whether only one operand is "true".
  *
  * @access public
  * @static
  * @param IBool\Type $x                                     the left operand
  * @param IBool\Type $y                                     the right operand
  * @return IBool\Type                                       whether only one operand is "true"
  *
  * @see http://en.wikipedia.org/wiki/Truth_table#Exclusive_disjunction
  */
 public static function xor_(IBool\Type $x, IBool\Type $y) : IBool\Type
 {
     return IBool\Type::box($x->unbox() xor $y->unbox());
 }
예제 #16
0
 /**
  * This method evaluates whether the left operand is less than the right operand.
  *
  * @access public
  * @static
  * @param ITrit\Type $x                                     the left operand
  * @param ITrit\Type $y                                     the right operand
  * @return IBool\Type                                       whether the left operand is less than
  *                                                          the right operand
  */
 public static function lt(ITrit\Type $x, ITrit\Type $y) : IBool\Type
 {
     // <
     return IBool\Type::box(ITrit\Module::compare($x, $y)->unbox() < 0);
 }
예제 #17
0
 /**
  * This method returns whether this character is an upper case character.
  *
  * @access public
  * @static
  * @param IChar\Type $x                                     the character to be evaluated
  * @return IBool\Type                                       whether this is an upper case
  *                                                          character
  *
  * @see http://php.net/manual/en/function.ctype-upper.php
  */
 public static function isUpperCase(IChar\Type $x) : IBool\Type
 {
     return IBool\Type::box(ctype_upper($x->unbox()));
 }