Package org.projog.core.term
Class ListUtils
- java.lang.Object
-
- org.projog.core.term.ListUtils
-
public final class ListUtils extends java.lang.ObjectHelper methods for performing common tasks with Prolog list data structures.- See Also:
List,ListFactory,TermUtils
-
-
Constructor Summary
Constructors Modifier Constructor Description privateListUtils()Private constructor as all methods are static.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisMember(Term element, Term list)Checks is a term can be unified with at least one element of a list.static java.util.List<Term>toJavaUtilList(Term list)Returns a newjava.util.Listcontaining the contents of the specifiedorg.projog.core.term.List.static java.util.List<Term>toSortedJavaUtilList(Term unsorted)Returns a newjava.util.Listcontaining the sorted contents of the specifiedorg.projog.core.term.List.
-
-
-
Method Detail
-
toJavaUtilList
public static java.util.List<Term> toJavaUtilList(Term list)
Returns a newjava.util.Listcontaining the contents of the specifiedorg.projog.core.term.List.Will return
nulliflistis neither of typeTermType.LISTorTermType.EMPTY_LIST, or iflistrepresents a partial list (i.e. a list that does not have an empty list as its tail).- See Also:
toSortedJavaUtilList(Term)
-
toSortedJavaUtilList
public static java.util.List<Term> toSortedJavaUtilList(Term unsorted)
Returns a newjava.util.Listcontaining the sorted contents of the specifiedorg.projog.core.term.List.The elements in the returned list will be ordered using the standard ordering of terms, as implemented by
TermComparator.Will return
nulliflistis neither of typeTermType.LISTorTermType.EMPTY_LIST, or iflistrepresents a partial list (i.e. a list that does not have an empty list as its tail).- See Also:
toJavaUtilList(Term)
-
isMember
public static boolean isMember(Term element, Term list)
Checks is a term can be unified with at least one element of a list.Iterates through each element of
listattempting to unify withelement. Returnstrueimmediately after the first unifiable element is found. Iflistcontains no elements that can be unified withelementthenfalseis returned.- Throws:
ProjogException- iflistis not of typeTermType#LISTorTermType#EMPTY_LIST
-
-