Class Nth

java.lang.Object
org.projog.core.predicate.builtin.list.Nth
All Implemented Interfaces:
PredicateFactory

public final class Nth extends Object implements PredicateFactory
nth0(X,Y,Z) / nth1(X,Y,Z) - examines an element of a list.

Indexing starts at 0 when using nth0. Indexing starts at 1 when using nth1.

  • Method Details

    • nth0

      public static Nth nth0()
    • nth1

      public static Nth nth1()
    • getPredicate

      public Predicate getPredicate(Term input)
      Description copied from interface: PredicateFactory
      Returns a Predicate to be used in the evaluation of a goal.
      Specified by:
      getPredicate in interface PredicateFactory
      Parameters:
      input - the term containing the arguments to use in the evaluation of the goal
      Returns:
      Predicate to be used in the evaluation of the goal
      See Also:
    • isRetryable

      public boolean isRetryable()
      Description copied from interface: PredicateFactory
      Should instances of this implementation be re-evaluated when backtracking?

      Some goals (e.g. X is 1) are only meant to be evaluated once (the statement is either true or false) while others (e.g. repeat(3)) are meant to be evaluated multiple times. For instances of Predicate that are designed to possibly have Predicate.evaluate() called on them multiple times for the same individual query this method should return true. For instances of Predicate that are designed to only be evaluated once per individual query this method should return false.

      Specified by:
      isRetryable in interface PredicateFactory
      Returns:
      true if an attempt should be made to re-evaluate instances of implementing classes when backtracking, false otherwise