/** * This method returns whether the iterator is still valid. * * @access public * @final * @return bool whether there are more objects */ public final function valid() : bool { return $this->i->unbox() < $this->xs->__size(); }
/** * This method returns the item at the specified index. * * @access public * @final * @param IInt32\Type $i the index of the item * @return Core\Type the item at the specified index */ public final function item(IInt32\Type $i) : Core\Type { return $this->value[$i->unbox()]; }
/** * This method returns the extracted slice of the string. * * @access public * @static * @param IString\Type $xs the left operand * @param IInt32\Type $offset the starting index * @param IInt32\Type $length the length of the slice * @return IString\Type the string */ public static function slice(IString\Type $xs, IInt32\Type $offset, IInt32\Type $length) : IString\Type { return IString\Type::box(mb_substr($xs->unbox(), $offset->unbox(), $length->unbox(), IChar\Type::UTF_8_ENCODING)); }
/** * This method creates a list of "n" length with every item set to the given object. * * @access public * @static * @param Core\Type $x the object to be replicated * @param IInt32\Type $n the number of times to replicate * @return ILinkedList\Type the collection */ public static function replicate(Core\Type $x, IInt32\Type $n) : ILinkedList\Type { if ($n->unbox() <= 0) { return ILinkedList\Type::nil(); } return ILinkedList\Type::cons($x, ILinkedList\Type::replicate($x, IInt32\Module::decrement($n))); }
/** * 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); }
/** * This method returns the number raised to the power of the specified exponent. * * @access public * @static * @param IInteger\Type $x the operand * @param IInt32\Type $exponent the exponent to be raised by * @return IInteger\Type the result */ public static function pow(IInteger\Type $x, IInt32\Type $exponent) : IInteger\Type { return IInteger\Type::box(gmp_strval(gmp_pow($x->unbox(), $exponent->unbox()))); }
/** * This method returns the number raised to the power of the specified exponent. * * @access public * @static * @param IFloat\Type $x the operand * @param IInt32\Type $exponent the exponent to be raised by * @return IFloat\Type the result */ public static function pow(IFloat\Type $x, IInt32\Type $exponent) : IFloat\Type { return IFloat\Type::box(pow($x->unbox(), $exponent->unbox())); }
/** * This method returns the item at the specified index. * * @access public * @final * @param IInt32\Type $i the index of the item * @return string the item at the specified index */ public final function __item(IInt32\Type $i) : string { return mb_substr($this->value, $i->unbox(), 1, IChar\Type::UTF_8_ENCODING); }
/** * This method returns the extracted slice of the list. * * @access public * @static * @param IArrayList\Type $xs the left operand * @param IInt32\Type $offset the starting index * @param IInt32\Type $length the length of the slice * @return IArrayList\Type the list */ public static function slice(IArrayList\Type $xs, IInt32\Type $offset, IInt32\Type $length) : IArrayList\Type { return IArrayList\Type::box(array_slice($xs->unbox(), $offset->unbox(), $length->unbox())); }
/** * This method returns the first "n" items in the list. * * @access public * @static * @param ILinkedList\Type $xs the left operand * @param IInt32\Type $n the number of items to take * @return ILinkedList\Type the list */ public static function take(ILinkedList\Type $xs, IInt32\Type $n) : ILinkedList\Type { if ($n->unbox() <= 0 || $xs->__isEmpty()) { return ILinkedList\Type::nil(); } return ILinkedList\Type::cons($xs->head(), ILinkedList\Module::take($xs->tail(), IInt32\Module::decrement($n))); }