root/trunk/examples/operators/local.lgt

Revision 4601, 0.7 KB (checked in by pmoura, 7 weeks ago)

Added svn:mime-type property to source files (set to text/x-logtalk).

  • Property svn:mime-type set to text/x-logtalk
  • Property svn:eol-style set to native
Line 
1
2% simple example of defining an operator local to a source file
3   
4
5:- op(200, xfx, edge).  % global operator, visible within all
6                        % entities defined in this source file
7
8:- object(graph).
9
10    :- public(path/3).
11    :- public((edge)/2).
12
13    path(Start, End, [Start, End]) :-
14        ::(Start edge End).
15    path(Start, End, [Start| Path]) :-
16        ::(Start edge Node),
17        path(Node, End, Path).
18
19:- end_object.
20
21
22:- object(graph1,
23    extends(graph)).
24
25    a edge b.
26    a edge c.
27    b edge d.
28    c edge d.
29
30:- end_object.
31
32
33:- object(graph2,
34    extends(graph)).
35
36    v1 edge v2.
37    v1 edge v3.
38    v2 edge v4.
39    v3 edge v4.
40
41:- end_object.
42
43
44:- op(0, xfx, edge).    % "undefine" the operator, effectively
45                        % making it local to this source file
Note: See TracBrowser for help on using the browser.