예제 #1
0
 /**
  * This method returns the current object.
  *
  * @access public
  * @final
  * @return mixed                                            the current object
  */
 public final function current()
 {
     return $this->ys->head();
 }
예제 #2
0
 /**
  * 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)));
 }