Class PrologList

All Implemented Interfaces:
Serializable, Comparable<PrologTerm>, Iterable<PrologTerm>

public final class PrologList extends PrologStruct implements Iterable<PrologTerm>
Representation of prolog list term.
See Also:
  • Field Details

    • LIST_FUNCTOR

      public static final PrologTerm LIST_FUNCTOR
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • EMPTY_ANONYMOUS_VAR

      private static final PrologVar EMPTY_ANONYMOUS_VAR
  • Constructor Details

    • PrologList

      public PrologList()
    • PrologList

      public PrologList(int line, int pos)
    • PrologList

      public PrologList(PrologTerm[] array)
    • PrologList

      public PrologList(PrologTerm[] array, int line, int pos)
    • PrologList

      public PrologList(PrologTerm head)
    • PrologList

      public PrologList(PrologTerm head, int line, int pos)
    • PrologList

      public PrologList(PrologTerm head, PrologTerm tail)
    • PrologList

      public PrologList(PrologTerm head, PrologTerm tail, int line, int pos)
  • Method Details

    • setTermAsNewListTail

      public static PrologList setTermAsNewListTail(PrologList list, PrologTerm term)
    • getTermAt

      public PrologTerm getTermAt(int index)
      Description copied from class: PrologCompound
      Get element for its position
      Overrides:
      getTermAt in class PrologStruct
      Parameters:
      index - zero-based element position
      Returns:
      element in position
    • isEmpty

      public boolean isEmpty()
      Description copied from class: PrologStruct
      Check that the structure has elements.
      Overrides:
      isEmpty in class PrologStruct
      Returns:
      true if there is not elements, false otherwise
    • getHead

      public PrologTerm getHead()
      Get the current head element of the list.
      Returns:
      the head element, can be null
    • setHead

      public void setHead(PrologTerm term)
      Replace the head element.
      Parameters:
      term - the new head term, can be null
    • getTail

      public PrologTerm getTail()
      Get the current tail element
      Returns:
      the current tail element, can be null
    • setTail

      public void setTail(PrologTerm term)
      Set the current tail element
      Parameters:
      term - the new tail element, can be null
    • addAsNewListToEndOfListChain

      public PrologList addAsNewListToEndOfListChain(PrologTerm term)
      Add term as new list into the end of the list chain.
      Parameters:
      term - to be added as new list in the end of chain
      Returns:
      generated list (may be this)
    • replaceEndListElement

      public void replaceEndListElement(PrologTerm newTailElement)
      Replace last tail element in list chain.
      Parameters:
      newTailElement - new element
    • getArity

      public int getArity()
      Description copied from class: PrologTerm
      Arity of element.
      Overrides:
      getArity in class PrologStruct
      Returns:
      arity of element, make sense for compound terms, for primitive terms is 1
    • setElementAt

      public void setElementAt(int index, PrologTerm term)
      Description copied from class: PrologStruct
      Set element for its position.
      Overrides:
      setElementAt in class PrologStruct
      Parameters:
      index - zero based index
      term - term to set to position
    • getType

      public TermType getType()
      Description copied from class: PrologTerm
      Get term type.
      Overrides:
      getType in class PrologStruct
      Returns:
      term type, must not be null
    • toString

      public String toString()
      Overrides:
      toString in class PrologStruct
    • iterator

      public Iterator<PrologTerm> iterator()
      Specified by:
      iterator in interface Iterable<PrologTerm>
      Overrides:
      iterator in class PrologStruct
    • stream

      public Stream<PrologTerm> stream()
      Overrides:
      stream in class PrologStruct