Do they exist? I have written a program that solves sudoku puzzles, and it takes 3 steps to run.
> prolog
> consult(sudoku).
> solve(puzzle).
I'm looking for a way to do something like
> prolog puzzle
and be done with it. Is there a way to do this IN Prolog? Or will I have to write some helper program in C or some other language to use like
> ./solve puzzle
Any help would be appreciated. Still new to Prolog, and having trouble finding good documentation.
It depends on the Prolog system your are using. Most Prolog systems have a command line
start where one can provide an initial Prolog text to be consulted and an
initial Prolog goal to be run.
Here are some examples, I have combined the consult and run into one conjunctive goal:
SWI-Prolog:
> swipl -t ['sudoku.p'],puzzle
GNU Prolog:
> gprolog --entry-goal ['sudoku.p'],puzzle,halt
Jekejeke Prolog:
> java -jar interpreter.jar -t ['sudoku.p'],puzzle
Best Regards
Using the -g
flag you can cause Prolog to execute a goal of your choice just before entering the top level. Default is a predicate which prints the welcome message. Moreover, you might like to use the -t
flag that would replace the default goal prolog/0 by the one of your choice as an interactive top-level.
See also the manual.