Class 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 Detail

      • firstArgNumeric

        private final boolean firstArgNumeric
      • convertToCharCodes

        private final boolean convertToCharCodes
    • Constructor Detail

      • TermSplit

        private TermSplit​(boolean firstArgNumeric,
                          boolean convertToCharCodes)
    • Method Detail

      • atomChars

        public static TermSplit atomChars()
      • atomCodes

        public static TermSplit atomCodes()
      • numberChars

        public static TermSplit numberChars()
      • numberCodes

        public static TermSplit numberCodes()
      • 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​(java.lang.StringBuffer sb,
                                                Term t)
      • stringToChar

        private char stringToChar​(java.lang.String name)
      • charToTerm

        protected Term charToTerm​(char c)
      • numericToChar

        private char numericToChar​(long n)
      • toTerm

        private Term toTerm​(java.lang.String s)
      • toNumeric

        private Numeric toNumeric​(java.lang.String s)
      • toInteger

        private IntegerNumber toInteger​(java.lang.String s)
      • toDecimal

        private Numeric toDecimal​(java.lang.String s)