A simple PROLOG problem: how do you test multiple queries in a Prolog database?

I have a Prolog database file (test_inserts.p) that I used to insert all my data.

I also have a Prolog request file (test_queries.pl), which has all the Prolog requests that I wrote to get specific information from my database.

I was wondering how to actually use the test_queries.pl queries for the test_inserts.p database file when using gprolog? . I was hoping it would be possible to load both at the same time, and somehow manage the request to run, instead of re-entering every request that I wanted to run ....

+5
source share
1

initialization/1 ISO test_queries.pl, , .

test_queries.pl

test :-
        findall(_, (a(X,Y), format('~w ~w~n', [X,Y])), _).

:- initialization([test_inserts]).
:- initialization(test).

test_inserts.pl

a(X,Y) :- append(X,Y,[1,2,3]).

gprolog --consult-file

gprolog --consult-file test_queries.pl
GNU Prolog 1.4.0
By Daniel Diaz
Copyright (C) 1999-2011 Daniel Diaz
compiling /home/carlo/test_queries.pl for byte code...
/home/carlo/test_queries.pl compiled, 5 lines read - 659 bytes written, 28 ms
compiling /home/carlo/test_inserts.pl for byte code...
/home/carlo/test_inserts.pl compiled, 2 lines read - 379 bytes written, 30 ms
[] [1,2,3]
[1] [2,3]
[1,2] [3]
[1,2,3] []
| ?- 
+5

All Articles