Hello!
My actual application is more complicated than the following illustrative predicate but I chose it as it is because it covers various features which I would need to handle. I tried around with initialization
and some of the swipl
attributes but cannot really get it to work and also can’t find good documentation on it.
Assuming this is stored in a file called app.pl:
t([X1, X2|[]], X3, Y) :-
Y1 is X1 + X2,
Y2 is 2 * X3,
Y = [Y1, Y2]
.
What I eventually want to be able to do is something like that (this is just plausible pseudo code):
swipl -f app.pl -c 't([1,2],3,Y)'
And then receive the response Y = [3,6]
for further processing on STDOUT.
I don’t really want to introduce necessarily a main
procedure. Though, it would also be interesting to see how that would work, too. But my eventual goal is to call individual predicates from Python or Bash for testing.
In fewer words, I want to emulate a single invocation in a swipl REPL session from the Linux command line.
I found a way to do it but I’m not super happy with the solution for obvious reasons.
➜ swipl -g "[app]." -g "t([1,2],3,Y), writeln(Y)" -g halt
[3,6]
It’s pretty hacky. I tried at least replacing -g "[app]."
with -f app.pl
but that failed. Also -F
, -l
, -s
didn’t work for loading the database.
Kind Regards
Raffael