import mProlog.*;

/**
 * Example application: Handling lists
 *
 * @project mProlog - Lightweight PROLOG Engine implementation (J2SE, J2ME)
 * @author Fernando Koch
 *
 * <pre>
 * This software may be distributed under the
 * GNU GENERAL PUBLIC LICENSE
 * Version 2, June 1991
 * {@link http://www.gnu.org/licenses/gpl.txt}.
 * </pre>
 */

public class MPrologTest004 {
  public static void main(String[] args) {
    PrologEngine prolog = new PrologEngine();
    prolog.add("addList(A,ELEMENT,RESULT):- eq(RESULT,A+ELEMENT)");
    PrologTerm goal = PrologTerm.create("addList([a,b],c,RESULT)");
    PrologQuery query = new PrologQuery(prolog, goal);
    PrologTerm[] solution = query.solution();
    if (solution != null) {
      System.out.println(solution[0].getVariableName() + "->" +
                         solution[0].getVariableValue());

      solution = query.solution();
    }
  }
}

