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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -