/** * This method tests the "ge" method. * * @dataProvider data_ge */ public function test_ge(array $provided, array $expected) { $p0 = IInt32\Module::ge(IInt32\Type::box($provided[0]), IInt32\Type::box($provided[1])); $e0 = $expected[0]; $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $p0); $this->assertSame($e0, $p0->unbox()); }
/** * This method returns the collection as a linked list. * * @access public * @static * @param IString\Type $xs the operand * @return ILinkedList\Type the collection as a linked list */ public static function toLinkedList(IString\Type $xs) : ILinkedList\Type { $length = $xs->length(); $zs = ILinkedList\Type::nil(); for ($i = IInt32\Module::decrement($length); IInt32\Module::ge($i, IInt32\Type::zero())->unbox(); $i = IInt32\Module::decrement($i)) { $zs = ILinkedList\Type::cons($xs->item($i), $zs); } return $zs; }
/** * This method applies a right-fold reduction on the list using the operation function. * * @access public * @static * @param IArrayList\Type $xs the left operand * @param callable $operator the operator function to be used * @param Core\Type $initial the initial value to be used * @return Core\Type the result */ public static function foldRight(IArrayList\Type $xs, callable $operator, Core\Type $initial) : Core\Type { $z = $initial; for ($i = IInt32\Module::decrement($xs->length()); IInt32\Module::ge($i, IInt32\Type::zero())->unbox(); $i = IInt32\Module::decrement($i)) { $z = $operator($z, $xs->item($i)); } return $z; }