Prologue: "Vanilla" metainterpreter with built-in

This answer from Jan Burse shows one of the simplest implementations of metainterpreter in Prolog:

solve(true) :- !.
solve((A,B)) :- !, solve(A), solve(B).
solve(H) :- clause(H,B), solve(B).

I would like to extend this interpreter so that it can call inline functions. Vanilla is not able to handle calls such as solve(member(X, [1,2,3,4])). Is it possible to use ISO predicates? If not, is it possible to use SWI-Prolog predicates?

+6
source share
2 answers

Stackoverflow refuses to accept my answer :) which was

Just call / 1 them

Edit

for example

?- [user].
solve(true) :- !.
|: solve((A,B)) :- !, solve(A), solve(B).
|: solve(H) :- clause(H,B), solve(B).
|: solve(T) :- call(T).
|: ^Dtrue.

?- solve(member(X, [1,2,3,4])).
X = 1 ;
X = 2 ;
X = 3 ;
X = 4.

The only addition: solve(T) :- call(T).

+1
source

I think that may be useful for your task. predicate_property/2

, () .

:

?- predicate_property((A,B), P).
P = interpreted ;
P = visible ;
P = built_in ;
P = static ;
P = imported_from(system) ;
etc.

, , .

SICStus.

: . , , , .

+2

All Articles