1
votes

In TurboPrologwe can use next construction:

goal:
  father('Tom', X).

How use same in SWI-Prolog?

2
Turbo Prolog is special here. Most other systems have initialization/1 as directive. - false

2 Answers

2
votes

If I recall what goal does, I suggest to use the ISO-Prolog built-in initialization/1:

Call Goal after loading the source file in which this directive appears has been completed.

:- initialization((father('Tom', X), writeln(X))).

I've added a visualization of the value obtained - if any. Also some error handling should be added...

0
votes

And how we can call 2 or more Goal?

Next code call error:

:- initialization(
       (grandmother('Sarah', X), writeln(X)),
       (father('Tom', Y), writeln(Y))
    ).