Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call facts and rules from another file

Case: I have a file, solution.pl, where I want to use the rules of another file (this is the definition of the program, not up to me, but I think it's somewhat common).

So I'm using Ciao Prolog and the syntax seems to be ensure_loaded('c:/Path').

but when I try to use the rules of the other file, it tells me he doesn't know what rule I'm trying to use.

On the other hand, if I write on the console that same lane, and then query again, it does work.

So I was wondering maybe the syntax for doing it on the console and on a file are different??

Could someone tell me a step by step so I can figure it out if I'm missing something? What I'm doing right now is loading the program as I would do with smaller programs, then try to query rules of the file included in the ensure_loaded command. And as I said, it does seem to work if write the command outside of the program.

like image 643
keont Avatar asked Dec 09 '25 16:12

keont


1 Answers

in solution.pl, try

:- ensure_loaded('c:/Path').

or, if the source in c:/Path has a module directive - that is, it begins with :- module(name, [exported/arity, ...]).

:- use_module('c:/Path').
like image 169
CapelliC Avatar answered Dec 11 '25 20:12

CapelliC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!