root/trunk/examples/metainterpreters/rules.lgt

Revision 4601, 0.8 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
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- category(engine).
3
4    :- public(prove/1).
5
6    :- public(if/1).
7    :- dynamic(if/1).
8
9    :- op(200,  fx, if).
10    :- op(150, xfx, then).
11    :- op(100, xfy, &).
12
13    prove(true) :-
14        !.
15    prove(Cond & Conds) :-
16        !,
17        prove(Cond),
18        prove(Conds).
19    prove(Fact) :-
20        clause(Fact, true).
21    prove(Conclusion) :-
22        clause(if Conds then Conclusion, true),
23        prove(Conds).
24
25:- end_category.
26
27
28:- object(rules,
29    imports(engine)).
30
31    :- public([weather/1, weekday/1, time/1, goto/1]).
32    :- dynamic([weather/1, weekday/1, time/1, goto/1]).
33
34    :- dynamic(if/1).
35
36    :- op(200,  fx, if).
37    :- op(150, xfx, then).
38    :- op(100, xfy, &).
39
40    if weather(sunny) & weekday(weekend) & time(day) then goto(beach).
41    if weather(raining) & weekday(weekend) & time(night) then goto(cinema).
42    if weekday(workday) & time(day) then goto(work).
43
44    weather(raining).
45    weekday(weekend).
46    time(night).
47
48:- end_object.
Note: See TracBrowser for help on using the browser.