I want to separate the data file into list of facts like functor(arg1, arg2, ..., argN)
which the name of functor is the uppercase line and the arguments are the lowercase lines that follow them,
subsequently, new clauses are saved in a prolog file created at the execution
file.txt
FUNCTOR1
arg1
arg2
FUNCTOR2
arg1
arg2
arg3
FUNCTOR3
arg1
arg2
arg3
arg4
result :
?- split_data_to_facts('file.txt',List,'file.pl').
List = ['functor1(arg1,arg2)','functor2(arg1,arg2,arg3)','functor3(arg1,arg2,arg3,arg4)'].
file.pl
"." will be appended as the last
functor1(arg1,arg2).
functor2(arg1,arg2,arg3).
functor3(arg1,arg2,arg3,arg4).
after building and compiling the new prolog file file.pl
:
?- functor2(X,Y,Z).
X=arg1,
Y=arg2,
Z=arg3;
yes