Question

boolean(true).
boolean(false).
formula_0(P, Q):- (P; Q), \+ P.

solution_for_formula(P, Q, Formula):-
    maplist(boolean, [P, Q]), call([Formula, P, Q]).

A follow-up to my earlier question. Why wouldn't this work? (If I replace call([Formula, P, Q]) with formula_0(P, Q) it works.)

Was it helpful?

Solution

You want call(Formula, P, Q), not call([Formula, P, Q]). Simply remove the square brackets. Try this to make it more clear what the error is:

?- write_canonical(call([Formula, P, Q])).
call('.'(_,'.'(_,'.'(_,[]))))
true.

I.e. with the square brackets, you are calling a (.)/2 predicate, which you (likely) don't define. But the high-order predicate that you want to call is call/3, whose arguments are call(Closure, Arg1, Arg2). E.g. call(formula_0, true, false) will call formula_0(true, false).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top