Skip to content

Instantly share code, notes, and snippets.

@rogual
Created August 21, 2017 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogual/c93e213398023b5f45be4d518d5b63b4 to your computer and use it in GitHub Desktop.
Save rogual/c93e213398023b5f45be4d518d5b63b4 to your computer and use it in GitHub Desktop.
Creating simple CLI programs with GNU Prolog
Creating simple CLI programs with GNU Prolog
This template shows how to compile a knowledge base to machine code and execute arbitrary Prolog queries against it by passing them as CLI arguments to a binary.
Output comes out on stdout with no banners or other rubbish.
.PHONY: run
simple: simple.pl
gplc --no-top-level $<
run: simple
./simple 'forall(ok(X), (write(X), nl)).'
:- initialization(main).
ok(a).
ok(b).
main :-
argument_value(1, X),
read_from_atom(X, T),
call(T).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment