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_codesatom_chars(A,L)compares the atomAto the list of charactersL.atom_codes(A,L)compares the atomAto the list of character codesL.number_chars(N,L)compares the numberNto the list of charactersL.number_codes(N,L)compares the numberNto the list of character codesL.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanconvertToCharCodesprivate booleanfirstArgNumeric
-
Constructor Summary
Constructors Modifier Constructor Description privateTermSplit(boolean firstArgNumeric, boolean convertToCharCodes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendListElementsToString(java.lang.StringBuffer sb, Term t)static TermSplitatomChars()static TermSplitatomCodes()protected TermcharToTerm(char c)protected booleanevaluate(Term arg1, Term arg2)private booleanevaluateWithConcreteFirstArgument(Term arg1, Term arg2)Convertsarg1to a list and attempts to unify it witharg2.private booleanevaluateWithVariableFirstArgument(Term arg1, Term arg2)Convertsarg2from a list to an atom and attempts to unify it witharg1.private booleanisNotList(Term t)private voidisValidConcreteFirstArgument(Term arg)static TermSplitnumberChars()static TermSplitnumberCodes()private charnumericToChar(long n)private charstringToChar(java.lang.String name)private NumerictoDecimal(java.lang.String s)private IntegerNumbertoInteger(java.lang.String s)private NumerictoNumeric(java.lang.String s)private TermtoTerm(java.lang.String s)-
Methods inherited from class org.projog.core.predicate.AbstractSingleResultPredicate
evaluate, evaluate, evaluate, evaluate, evaluate, getArithmeticOperators, getFileHandles, getKnowledgeBase, getOperands, getPredicate, getPredicates, getProjogListeners, getSpyPoints, getTermFormatter, init, isRetryable, setKnowledgeBase
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.projog.core.predicate.PredicateFactory
isAlwaysCutOnBacktrack
-
-
-
-
Method Detail
-
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:
evaluatein classAbstractSingleResultPredicate
-
evaluateWithVariableFirstArgument
private boolean evaluateWithVariableFirstArgument(Term arg1, Term arg2)
Convertsarg2from a list to an atom and attempts to unify it witharg1.Example of a prolog query that would cause this method to be used:
?- number_chars(X, [1,4,2]). X = 142
- Parameters:
arg1- aVariablearg2- aList- Returns:
trueif was able to unify
-
evaluateWithConcreteFirstArgument
private boolean evaluateWithConcreteFirstArgument(Term arg1, Term arg2)
Convertsarg1to a list and attempts to unify it witharg2.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- aAtomorNumericarg2- in order to unify, this argument must represent aAtomorList- Returns:
trueif 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)
-
-