Prolog term_expansion not working -
i trying perform following term_expansion swipl:
a(asda). a(astronaut). term_expansion(a(x),b(x)).
but not work, i.e. there no b/1 consulted. have tried few variations:
term_expansion(a(x),[b(x)]). user:term_expansion(a(x),b(x)). user:term_expansion(a(x),[b(x)]). user:term_expansion(user:a(x),[user:b(x)]).
none of works. problem?
as explained @mat, need define term_expansion/2
predicate before clauses want expand loaded. also, term_expansion/2
predicate multifile , dynamic predicate defined user
pseudo-module. thus, should write:
:- multifile user:term_expansion/2. :- dynamic user:term_expansion/2. user:term_expansion(a(x), b(x)).
this ensure expansion code work if move module.
if portability other prolog systems term-expansion mechanism (which, btw, far standard), consider moving term-expansion code own file, loaded before source files want expand.
Comments
Post a Comment