i have prolog file following structure:
% library section % foo(x) :- bar(x); baz(x). % user data section % % e.g. bar(charlie). the user data of file intended allowed extended user default contains nothing. causes query foo(x). fails because bar/1 , baz/1 not defined.
i have tried defining them placeholder values (i.e. bar(none).) gnu prolog complains discontiguous predicates when user data added bottom of file.
is there way define dummy/placeholder version of bar/1 , baz/1 foo(x). not fail , other lines containing bar , baz can added bottom of file?
if understand question, want have along lines of:
ask_bar :- % user input assertz(bar(input)). foo(x) :- bar(x).
if indeed problem, have 2 options:
first one: declare bar/1 dynamic predicate:
:- dynamic(bar/1). (this directive, type :- @ beginning of line.)
second one: in program, before reference bar/1, call predicate retractall/1, this:
main :- retractall(bar(_)), %....
this delete bars database, and declare bar/1 dynamic.
Comments
Post a Comment