MCPcopy Create free account
hub / github.com/SWI-Prolog/packages-jpl / listToTermArray

Method listToTermArray

src/main/java/org/jpl7/Term.java:1063–1074  ·  view source on GitHub ↗

Converts a proper list to an array of terms, else throws an exception @param t the Term representing a list @throws JPLException if the term passed is not itself a Prolog list term @return an array of terms whose successive elements are the corresponding members of the list (if it is a list)

(Term t)

Source from the content-addressed store, hash-verified

1061 * @return an array of terms whose successive elements are the corresponding members of the list (if it is a list)
1062 */
1063 public static Term[] listToTermArray(Term t) {
1064 int len = Term.listLength(t); // exception if not a well formed list
1065 if (len < 0) {
1066 throw new JPLException("term is not a proper list");
1067 }
1068 Term[] ts = new Term[len];
1069 for (int i = 0; i < len; i++) { // no need to check functor (it's a list)
1070 ts[i] = t.arg(1);
1071 t = t.arg(2);
1072 }
1073 return ts;
1074 }
1075
1076 /**
1077 * Converts a proper list to an array of terms, else throws an exception

Callers 9

testTermToTermArray1Method · 0.95
testTextToTerm2Method · 0.95
textToTermMethod · 0.95
toTermArrayMethod · 0.95
DictMethod · 0.95
putParamsMethod · 0.45

Calls 2

listLengthMethod · 0.95
argMethod · 0.45

Tested by 5

testTermToTermArray1Method · 0.76
testTextToTerm2Method · 0.76