root/trunk/examples/polygons/SCRIPT.txt

Revision 4662, 2.3 KB (checked in by pmoura, 5 days ago)

Updated copyright notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1================================================================
2Logtalk - Open source object-oriented logic programming language
3Release 2.35.0
4
5Copyright (c) 1998-2009 Paulo Moura.        All Rights Reserved.
6Logtalk is free software.  You can redistribute it and/or modify
7it under the terms of the "Artistic License 2.0" as published by
8The Perl Foundation. Consult the "LICENSE.txt" file for details.
9================================================================
10
11
12% start by loading the example and the required library files:
13
14| ?- logtalk_load(polygons(loader)).
15...
16
17
18% first create four polygons and move each one to a different position
19
20| ?- triangle::new(t, [position-(4, 5)]).
21yes
22
23| ?- square::new(s, [position-(3, 2)]).
24yes
25
26| ?- pentagon::new(p, [position-(7, 1)]).
27yes
28
29| ?- hexagon::new(h, [position-(2, 4)]).
30yes
31
32
33% create two tuples of relation concentric
34
35| ?- concentric::add_tuple([t, s]).
36yes
37
38| ?- concentric::add_tuple([p, h]).
39yes
40
41
42% check results
43
44| ?- concentric::tuple(Tuple), write(Tuple), nl, fail.
45[t,s]
46[p,h]
47no
48
49| ?- t::position(Xt, Yt), s::position(Xs, Ys), p::position(Xp, Yp), h::position(Xh, Yh).
50Xh = 7,
51Yh = 1,
52Xp = 7,
53Xs = 4,
54Xt = 4,
55Yp = 1,
56Ys = 5,
57Yt = 5
58yes
59
60| ?- after_event_registry::monitors(Ma).
61Ma = [concentric]
62yes
63
64
65% move the triangle and the hexagon to new positions
66
67| ?- t::move(3, 3), h::move(8, 4).
68yes
69
70
71% check results
72
73| ?- concentric::tuple(Tuple), write(Tuple), nl, fail.
74[t,s]
75[p,h]
76no
77
78| ?- t::position(Xt, Yt), s::position(Xs, Ys), p::position(Xp, Yp), h::position(Xh, Yh).
79Xh = 8,
80Yh = 4,
81Xp = 8,
82Xs = 3,
83Xt = 3,
84Yp = 4,
85Ys = 3,
86Yt = 3
87yes
88
89| ?- after_event_registry::monitors(Ma).
90Ma = [concentric]
91yes
92
93
94% create another tuple of relation concentric
95
96| ?- concentric::add_tuple([t, p]).
97yes
98
99
100% move the pentagon to a new position
101
102| ?- p::move(2, 7).
103yes
104
105
106% check results
107
108| ?- concentric::tuple(Tuple), write(Tuple), nl, fail.
109[t,s]
110[p,h]
111[t,p]
112no
113
114| ?- t::position(Xt, Yt), s::position(Xs, Ys), p::position(Xp, Yp), h::position(Xh, Yh).
115Xh = 2,
116Yh = 7,
117Xp = 2,
118Xs = 2,
119Xt = 2,
120Yp = 7,
121Ys = 7,
122Yt = 7
123yes
124
125| ?- after_event_registry::monitors(Monitors).
126Monitors = [concentric]
127yes
128
129
130% clean up instances, tuples and monitors
131
132| ?- concentric::remove_all_tuples.
133yes
134
135| ?- triangle::delete(t).
136yes
137
138| ?- square::delete(s).
139yes
140
141| ?- pentagon::delete(p).
142yes
143
144| ?- hexagon::delete(h).
145yes
Note: See TracBrowser for help on using the browser.