/** * 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->ys = $this->ys->tail(); $this->i = IInt32\Module::increment($this->i); return IBool\Type::box($this->valid()); }
/** * 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))); }