Search code examples
prologswi-prologprolog-toplevel

Prolog, on start executing write something


I want to display a string on terminal when the user executes it. But, I want to do this without calling any predicate. For example, if the code is like this:

print_sth(String):-write(String).

it will print some string only if I make an explicit call of that predicate. Instead, when we consult our program I want the view to be something like this:

This is a brief tutorial of the program that was called automatically. 
?- // Ready to call a predicate here, but the string above was displayed when we consulted the program.  

I tried this but it didn't work:

:- write('This is a brief tutorial of the program that was called automatically. ').
some_predicate():- do_sth().
// ... other stuff follows here.

Thank you!


Solution

  • :- initialization(writeln('hello world')).