@Predicate(name = "arg", arity = 3) public AbstractGoal arg(JavaCallGoal goal) throws Exception { // FIXME check overflow??? int arg = (int) goal.getLongArg(0); RuntimeStruct term = goal.getStructArg(1); return goal.unify(2, term.data[arg]); }
@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(); } }