@Predicate(name = "copy_term", arity = 2) public AbstractGoal copyTerm(JavaCallGoal goal) throws Exception { Object left = RuntimeVariable.copyTerm(goal.getArg(0)); if (!goal.Q.unify(left, goal.getArg(1))) { return goal.Q.backtrack(); } return goal.G; }
@Predicate(name = "functor_ioo", arity = 3) public AbstractGoal functor_ioo(JavaCallGoal goal) throws Exception { RuntimeStruct struct = goal.getStructArg(0); Integer arity = struct.data.length - 1; String functor = (String) struct.data[0]; if (goal.Q.unify(goal.getArg(1), functor) && goal.Q.unify(goal.getArg(2), arity)) { return goal.G; } else { return goal.Q.backtrack(); } }
@SuppressWarnings("unchecked") @Predicate(name = "map_get", arity = 3) public AbstractGoal getMap(JavaCallGoal goal) throws Exception { Object a3 = goal.getArg(2); Object o = ((java.util.Map<Object, Object>) goal.getArg(0)).get(goal.getArg(1)); if (goal.Q.unify(a3, o)) { return goal.G; } else { return goal.Q.backtrack(); } }
@Predicate(name = "var", arity = 1) public AbstractGoal var(JavaCallGoal goal) throws Exception { Object a1 = goal.getArg(0); if (a1.getClass() == RuntimeVariable.class) { return goal.G; } else { return goal.Q.backtrack(); } }