Class TermSplit

java.lang.Object
org.projog.core.predicate.AbstractSingleResultPredicate
org.projog.core.predicate.builtin.construct.TermSplit
All Implemented Interfaces:
KnowledgeBaseConsumer, PredicateFactory

public final class TermSplit extends AbstractSingleResultPredicate
atom_chars / atom_codes / number_chars / number_codes

  • atom_chars(A,L) compares the atom A to the list of characters L.
  • atom_codes(A,L) compares the atom A to the list of character codes L.
  • number_chars(N,L) compares the number N to the list of characters L.
  • number_codes(N,L) compares the number N to the list of character codes L.
  • Field Details

    • firstArgNumeric

      private final boolean firstArgNumeric
    • convertToCharCodes

      private final boolean convertToCharCodes
  • Constructor Details

    • TermSplit

      private TermSplit(boolean firstArgNumeric, boolean convertToCharCodes)
  • Method Details

    • atomChars

      public static TermSplit atomChars()
    • atomCodes

      public static TermSplit atomCodes()
    • numberChars

      public static TermSplit numberChars()
    • numberCodes

      public static TermSplit numberCodes()
    • evaluate

      protected boolean evaluate(Term arg1, Term arg2)
      Overrides:
      evaluate in class AbstractSingleResultPredicate
    • evaluateWithVariableFirstArgument

      private boolean evaluateWithVariableFirstArgument(Term arg1, Term arg2)
      Converts arg2 from a list to an atom and attempts to unify it with arg1.

      Example of a prolog query that would cause this method to be used:

      ?- number_chars(X, [1,4,2]).
      X = 142
      
      Parameters:
      arg1 - a Variable
      arg2 - a List
      Returns:
      true if was able to unify
    • evaluateWithConcreteFirstArgument

      private boolean evaluateWithConcreteFirstArgument(Term arg1, Term arg2)
      Converts arg1 to a list and attempts to unify it with arg2.

      Example of a prolog query that would cause this method to be used:

      ?- atom_chars(apple, X).
      X = [a,p,p,l,e]
      
      Parameters:
      arg1 - a Atom or Numeric
      arg2 - in order to unify, this argument must represent a Atom or List
      Returns:
      true if was able to unify
    • isValidConcreteFirstArgument

      private void isValidConcreteFirstArgument(Term arg)
    • isNotList

      private boolean isNotList(Term t)
    • appendListElementsToString

      private void appendListElementsToString(StringBuffer sb, Term t)
    • stringToChar

      private char stringToChar(String name)
    • charToTerm

      protected Term charToTerm(char c)
    • numericToChar

      private char numericToChar(long n)
    • toTerm

      private Term toTerm(String s)
    • toNumeric

      private Numeric toNumeric(String s)
    • toInteger

      private IntegerNumber toInteger(String s)
    • toDecimal

      private Numeric toDecimal(String s)