Defining a module in Prolog

I have some problems defining a module. Here's a short code abbreviation:

:- module(my_module, [word/1]). :- module(my_module, [alias_of/2]). alias_of(A, B) :- alias_of(A, C), alias_of(C, B). alias_of('Word_1', 'Word_2'). word(A) :- alias_of(B, A), word(B). word('Word_1'). word('Word_3'). 

And this is the output of SWI-Prolog when I consult the file:

 1 ?- ERROR: (i:/dev/prolog-workspace/trial.0.pro:2): Undefined procedure: my_module:module/2 However, there are definitions for: module/1 Warning: (i:/dev/prolog-workspace/trial.0.pro:2): Goal (directive) failed: my_module:module(my_module, [alias_of/2]) 

I thought that from the textbooks I read, I can expose predicates with : - module (module_name, [predicate_name / arity]) . What's wrong?

EDIT: since I was playing with this code now and testing it as a module, I realized that it is fully listening ...

+4
source share
1 answer
Module

should be the first directive and should only appear once.

 :- module(my_module, [word/1, alias_of/2]). ... etc... 
+4
source

Source: https://habr.com/ru/post/1393638/


All Articles