Skip to content

Querying Prolog code with Prolog? #2808

Answered by jjtolton
jjtolton asked this question in Q&A
Discussion options

You must be logged in to vote

For lack of a better answer, I'm going to go with this approach as the best current concise fully working answer for reading in a list of terms in a file in Scryer Prolog. Happy to relabel that if anyone has a different suggestion. Thanks to @hurufu for revealing the meat of the technique.

%% /tmp/warmup.pl
:- use_module(library(iso_ext)).
:- use_module(library(lambda)).
:- use_module(library(format)).
:- use_module(library(reif)).
:- use_module(library(dif)).
:- use_module(library(debug)).

slurp_terms_(Stream, Terms0, Terms) :-
        catch((read_term(Stream, Term, []),
               slurp_terms_(Stream, [Term|Terms0], Terms)
              ),
              error(syntax_error(incomplet…

Replies: 3 comments 17 replies

Comment options

You must be logged in to vote
15 replies
@jjtolton
Comment options

@hurufu
Comment options

@jjtolton
Comment options

@jjtolton
Comment options

Answer selected by jjtolton
Comment options

You must be logged in to vote
2 replies
@adri326
Comment options

@triska
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants