Logtalk 2.29.5 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1859 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
45
Logtalk/examples/operators/local.lgt
Normal file
45
Logtalk/examples/operators/local.lgt
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
% simple example of defining an operator local to a source file
|
||||
|
||||
|
||||
:- op(200, xfx, edge). % global operator, visible within all
|
||||
% entities defined in this source file
|
||||
|
||||
:- object(graph).
|
||||
|
||||
:- public(path/3).
|
||||
:- public((edge)/2).
|
||||
|
||||
path(Start, End, [Start, End]) :-
|
||||
::(Start edge End).
|
||||
path(Start, End, [Start| Path]) :-
|
||||
::(Start edge Node),
|
||||
path(Node, End, Path).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(graph1,
|
||||
extends(graph)).
|
||||
|
||||
a edge b.
|
||||
a edge c.
|
||||
b edge d.
|
||||
c edge d.
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(graph2,
|
||||
extends(graph)).
|
||||
|
||||
v1 edge v2.
|
||||
v1 edge v3.
|
||||
v2 edge v4.
|
||||
v3 edge v4.
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- op(0, xfx, edge). % "undefine" the operator, effectively
|
||||
% making it local to this source file
|
Reference in New Issue
Block a user