/** * This method returns an array of sub-strings that were split on the regular expression. * * @access public * @static * @param IRegex\Type $x the regular expression * @param Core\Type $ys the object to be split * @return IArrayList\Type an array of sub-strings */ public static function split(IRegex\Type $x, Core\Type $ys) : IArrayList\Type { $zs = $ys instanceof ITuple\Type ? preg_split($x->unbox(), $ys->first()->__toString(), (int) $ys->second()->unbox()) : preg_split($x->unbox(), $ys->__toString()); return IArrayList\Type::box(array_map(function ($z) { return IString\Type::box($z); }, $zs)); }
/** * 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); }