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

Method oneSolution

src/main/java/org/jpl7/Query.java:867–880  ·  view source on GitHub ↗

Returns the first solution, if any, as a (possibly empty) Map of variablename-to-term bindings, else null. This method will throw a JPLException if this Query is already open (and the Query will remain open as before). Otherwise, upon return, the Query will be closed. @return the first solution, i

()

Source from the content-addressed store, hash-verified

865 * no solutions.
866 */
867 public final Map<String, Term> oneSolution() {
868 if (open) {
869 throw new JPLException("Query is already open");
870 } else {
871 Map<String, Term> solution;
872 if (hasMoreSolutions()) {
873 solution = nextSolution();
874 close(); // safe, whether or not this is the only solution
875 } else {
876 solution = null;
877 }
878 return solution;
879 }
880 }
881
882 /**
883 * This static method creates a Query (whose goal is the specified Term) and

Callers 15

facMethod · 0.95
testListNil1Method · 0.95
testListNil2Method · 0.95
testListNil3Method · 0.95
testIsListMethod · 0.95
testListCons1Method · 0.95
testLength1Method · 0.95
testPutShortList1Method · 0.95
testPutLongList1Method · 0.95
testEmptyParenthesesMethod · 0.95

Calls 3

hasMoreSolutionsMethod · 0.95
nextSolutionMethod · 0.95
closeMethod · 0.95

Tested by 15

facMethod · 0.76
testListNil1Method · 0.76
testListNil2Method · 0.76
testListNil3Method · 0.76
testIsListMethod · 0.76
testListCons1Method · 0.76
testLength1Method · 0.76
testPutShortList1Method · 0.76
testPutLongList1Method · 0.76
testEmptyParenthesesMethod · 0.76