porolog 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/coverage/badge.svg +1 -0
- data/coverage/index.html +7090 -0
- data/doc/Porolog.html +337 -0
- data/doc/_index.html +187 -0
- data/doc/class_list.html +51 -0
- data/doc/file.README.html +250 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +250 -0
- data/doc/method_list.html +403 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/porolog/arguments.rb +173 -0
- data/lib/porolog/predicate.rb +3 -2
- data/lib/porolog/scope.rb +3 -2
- data/lib/porolog.rb +4 -2
- data/test/porolog/arguments_test.rb +790 -0
- data/test/porolog/porolog_test.rb +67 -0
- data/test/porolog/predicate_test.rb +27 -9
- data/test/porolog/scope_test.rb +13 -13
- data/test/test_helper.rb +22 -2
- metadata +20 -3
@@ -0,0 +1,403 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
|
+
<meta charset="utf-8" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
+
|
17
|
+
|
18
|
+
<title>Method List</title>
|
19
|
+
<base id="base_target" target="_parent" />
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<div id="content">
|
23
|
+
<div class="fixed_header">
|
24
|
+
<h1 id="full_list_header">Method List</h1>
|
25
|
+
<div id="full_list_nav">
|
26
|
+
|
27
|
+
<span><a target="_self" href="class_list.html">
|
28
|
+
Classes
|
29
|
+
</a></span>
|
30
|
+
|
31
|
+
<span><a target="_self" href="method_list.html">
|
32
|
+
Methods
|
33
|
+
</a></span>
|
34
|
+
|
35
|
+
<span><a target="_self" href="file_list.html">
|
36
|
+
Files
|
37
|
+
</a></span>
|
38
|
+
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">Search: <input type="text" /></div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<ul id="full_list" class="method">
|
45
|
+
|
46
|
+
|
47
|
+
<li class="odd ">
|
48
|
+
<div class="item">
|
49
|
+
<span class='object_link'><a href="Porolog/Arguments.html#<<-instance_method" title="Porolog::Arguments#<< (method)">#<<</a></span>
|
50
|
+
<small>Porolog::Arguments</small>
|
51
|
+
</div>
|
52
|
+
</li>
|
53
|
+
|
54
|
+
|
55
|
+
<li class="even ">
|
56
|
+
<div class="item">
|
57
|
+
<span class='object_link'><a href="Porolog/Predicate.html#<<-instance_method" title="Porolog::Predicate#<< (method)">#<<</a></span>
|
58
|
+
<small>Porolog::Predicate</small>
|
59
|
+
</div>
|
60
|
+
</li>
|
61
|
+
|
62
|
+
|
63
|
+
<li class="odd ">
|
64
|
+
<div class="item">
|
65
|
+
<span class='object_link'><a href="Porolog/Arguments.html#==-instance_method" title="Porolog::Arguments#== (method)">#==</a></span>
|
66
|
+
<small>Porolog::Arguments</small>
|
67
|
+
</div>
|
68
|
+
</li>
|
69
|
+
|
70
|
+
|
71
|
+
<li class="even ">
|
72
|
+
<div class="item">
|
73
|
+
<span class='object_link'><a href="Porolog/Scope.html#[]-instance_method" title="Porolog::Scope#[] (method)">#[]</a></span>
|
74
|
+
<small>Porolog::Scope</small>
|
75
|
+
</div>
|
76
|
+
</li>
|
77
|
+
|
78
|
+
|
79
|
+
<li class="odd ">
|
80
|
+
<div class="item">
|
81
|
+
<span class='object_link'><a href="Porolog/Predicate.html#[]-class_method" title="Porolog::Predicate.[] (method)">[]</a></span>
|
82
|
+
<small>Porolog::Predicate</small>
|
83
|
+
</div>
|
84
|
+
</li>
|
85
|
+
|
86
|
+
|
87
|
+
<li class="even ">
|
88
|
+
<div class="item">
|
89
|
+
<span class='object_link'><a href="Porolog/Scope.html#[]-class_method" title="Porolog::Scope.[] (method)">[]</a></span>
|
90
|
+
<small>Porolog::Scope</small>
|
91
|
+
</div>
|
92
|
+
</li>
|
93
|
+
|
94
|
+
|
95
|
+
<li class="odd ">
|
96
|
+
<div class="item">
|
97
|
+
<span class='object_link'><a href="Porolog/Scope.html#[]=-instance_method" title="Porolog::Scope#[]= (method)">#[]=</a></span>
|
98
|
+
<small>Porolog::Scope</small>
|
99
|
+
</div>
|
100
|
+
</li>
|
101
|
+
|
102
|
+
|
103
|
+
<li class="even ">
|
104
|
+
<div class="item">
|
105
|
+
<span class='object_link'><a href="Porolog/Arguments.html#arguments-instance_method" title="Porolog::Arguments#arguments (method)">#arguments</a></span>
|
106
|
+
<small>Porolog::Arguments</small>
|
107
|
+
</div>
|
108
|
+
</li>
|
109
|
+
|
110
|
+
|
111
|
+
<li class="odd ">
|
112
|
+
<div class="item">
|
113
|
+
<span class='object_link'><a href="Porolog/Arguments.html#arguments-class_method" title="Porolog::Arguments.arguments (method)">arguments</a></span>
|
114
|
+
<small>Porolog::Arguments</small>
|
115
|
+
</div>
|
116
|
+
</li>
|
117
|
+
|
118
|
+
|
119
|
+
<li class="even ">
|
120
|
+
<div class="item">
|
121
|
+
<span class='object_link'><a href="Porolog/Predicate.html#arguments-instance_method" title="Porolog::Predicate#arguments (method)">#arguments</a></span>
|
122
|
+
<small>Porolog::Predicate</small>
|
123
|
+
</div>
|
124
|
+
</li>
|
125
|
+
|
126
|
+
|
127
|
+
<li class="odd ">
|
128
|
+
<div class="item">
|
129
|
+
<span class='object_link'><a href="Porolog/Predicate.html#builtin-class_method" title="Porolog::Predicate.builtin (method)">builtin</a></span>
|
130
|
+
<small>Porolog::Predicate</small>
|
131
|
+
</div>
|
132
|
+
</li>
|
133
|
+
|
134
|
+
|
135
|
+
<li class="even ">
|
136
|
+
<div class="item">
|
137
|
+
<span class='object_link'><a href="Porolog/Predicate.html#call-instance_method" title="Porolog::Predicate#call (method)">#call</a></span>
|
138
|
+
<small>Porolog::Predicate</small>
|
139
|
+
</div>
|
140
|
+
</li>
|
141
|
+
|
142
|
+
|
143
|
+
<li class="odd ">
|
144
|
+
<div class="item">
|
145
|
+
<span class='object_link'><a href="Porolog/Arguments.html#cut_fact!-instance_method" title="Porolog::Arguments#cut_fact! (method)">#cut_fact!</a></span>
|
146
|
+
<small>Porolog::Arguments</small>
|
147
|
+
</div>
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
<li class="even ">
|
152
|
+
<div class="item">
|
153
|
+
<span class='object_link'><a href="Porolog/Arguments.html#cut_falicy!-instance_method" title="Porolog::Arguments#cut_falicy! (method)">#cut_falicy!</a></span>
|
154
|
+
<small>Porolog::Arguments</small>
|
155
|
+
</div>
|
156
|
+
</li>
|
157
|
+
|
158
|
+
|
159
|
+
<li class="odd ">
|
160
|
+
<div class="item">
|
161
|
+
<span class='object_link'><a href="Porolog/Arguments.html#dup-instance_method" title="Porolog::Arguments#dup (method)">#dup</a></span>
|
162
|
+
<small>Porolog::Arguments</small>
|
163
|
+
</div>
|
164
|
+
</li>
|
165
|
+
|
166
|
+
|
167
|
+
<li class="even ">
|
168
|
+
<div class="item">
|
169
|
+
<span class='object_link'><a href="Porolog/Arguments.html#evaluates-instance_method" title="Porolog::Arguments#evaluates (method)">#evaluates</a></span>
|
170
|
+
<small>Porolog::Arguments</small>
|
171
|
+
</div>
|
172
|
+
</li>
|
173
|
+
|
174
|
+
|
175
|
+
<li class="odd ">
|
176
|
+
<div class="item">
|
177
|
+
<span class='object_link'><a href="Porolog/Arguments.html#fact!-instance_method" title="Porolog::Arguments#fact! (method)">#fact!</a></span>
|
178
|
+
<small>Porolog::Arguments</small>
|
179
|
+
</div>
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
<li class="even ">
|
184
|
+
<div class="item">
|
185
|
+
<span class='object_link'><a href="Porolog/Arguments.html#falicy!-instance_method" title="Porolog::Arguments#falicy! (method)">#falicy!</a></span>
|
186
|
+
<small>Porolog::Arguments</small>
|
187
|
+
</div>
|
188
|
+
</li>
|
189
|
+
|
190
|
+
|
191
|
+
<li class="odd ">
|
192
|
+
<div class="item">
|
193
|
+
<span class='object_link'><a href="Porolog/Arguments.html#goal-instance_method" title="Porolog::Arguments#goal (method)">#goal</a></span>
|
194
|
+
<small>Porolog::Arguments</small>
|
195
|
+
</div>
|
196
|
+
</li>
|
197
|
+
|
198
|
+
|
199
|
+
<li class="even ">
|
200
|
+
<div class="item">
|
201
|
+
<span class='object_link'><a href="Porolog/Arguments.html#initialize-instance_method" title="Porolog::Arguments#initialize (method)">#initialize</a></span>
|
202
|
+
<small>Porolog::Arguments</small>
|
203
|
+
</div>
|
204
|
+
</li>
|
205
|
+
|
206
|
+
|
207
|
+
<li class="odd ">
|
208
|
+
<div class="item">
|
209
|
+
<span class='object_link'><a href="Porolog/Scope.html#initialize-instance_method" title="Porolog::Scope#initialize (method)">#initialize</a></span>
|
210
|
+
<small>Porolog::Scope</small>
|
211
|
+
</div>
|
212
|
+
</li>
|
213
|
+
|
214
|
+
|
215
|
+
<li class="even ">
|
216
|
+
<div class="item">
|
217
|
+
<span class='object_link'><a href="Porolog/Predicate.html#initialize-instance_method" title="Porolog::Predicate#initialize (method)">#initialize</a></span>
|
218
|
+
<small>Porolog::Predicate</small>
|
219
|
+
</div>
|
220
|
+
</li>
|
221
|
+
|
222
|
+
|
223
|
+
<li class="odd ">
|
224
|
+
<div class="item">
|
225
|
+
<span class='object_link'><a href="Porolog/Predicate.html#inspect-instance_method" title="Porolog::Predicate#inspect (method)">#inspect</a></span>
|
226
|
+
<small>Porolog::Predicate</small>
|
227
|
+
</div>
|
228
|
+
</li>
|
229
|
+
|
230
|
+
|
231
|
+
<li class="even ">
|
232
|
+
<div class="item">
|
233
|
+
<span class='object_link'><a href="Porolog/Arguments.html#inspect-instance_method" title="Porolog::Arguments#inspect (method)">#inspect</a></span>
|
234
|
+
<small>Porolog::Arguments</small>
|
235
|
+
</div>
|
236
|
+
</li>
|
237
|
+
|
238
|
+
|
239
|
+
<li class="odd ">
|
240
|
+
<div class="item">
|
241
|
+
<span class='object_link'><a href="Porolog/Arguments.html#myid-instance_method" title="Porolog::Arguments#myid (method)">#myid</a></span>
|
242
|
+
<small>Porolog::Arguments</small>
|
243
|
+
</div>
|
244
|
+
</li>
|
245
|
+
|
246
|
+
|
247
|
+
<li class="even ">
|
248
|
+
<div class="item">
|
249
|
+
<span class='object_link'><a href="Porolog/Predicate.html#name-instance_method" title="Porolog::Predicate#name (method)">#name</a></span>
|
250
|
+
<small>Porolog::Predicate</small>
|
251
|
+
</div>
|
252
|
+
</li>
|
253
|
+
|
254
|
+
|
255
|
+
<li class="odd ">
|
256
|
+
<div class="item">
|
257
|
+
<span class='object_link'><a href="Porolog/Scope.html#name-instance_method" title="Porolog::Scope#name (method)">#name</a></span>
|
258
|
+
<small>Porolog::Scope</small>
|
259
|
+
</div>
|
260
|
+
</li>
|
261
|
+
|
262
|
+
|
263
|
+
<li class="even ">
|
264
|
+
<div class="item">
|
265
|
+
<span class='object_link'><a href="Porolog/Predicate.html#new-class_method" title="Porolog::Predicate.new (method)">new</a></span>
|
266
|
+
<small>Porolog::Predicate</small>
|
267
|
+
</div>
|
268
|
+
</li>
|
269
|
+
|
270
|
+
|
271
|
+
<li class="odd ">
|
272
|
+
<div class="item">
|
273
|
+
<span class='object_link'><a href="Porolog/Scope.html#new-class_method" title="Porolog::Scope.new (method)">new</a></span>
|
274
|
+
<small>Porolog::Scope</small>
|
275
|
+
</div>
|
276
|
+
</li>
|
277
|
+
|
278
|
+
|
279
|
+
<li class="even ">
|
280
|
+
<div class="item">
|
281
|
+
<span class='object_link'><a href="Porolog/Arguments.html#predicate-instance_method" title="Porolog::Arguments#predicate (method)">#predicate</a></span>
|
282
|
+
<small>Porolog::Arguments</small>
|
283
|
+
</div>
|
284
|
+
</li>
|
285
|
+
|
286
|
+
|
287
|
+
<li class="odd ">
|
288
|
+
<div class="item">
|
289
|
+
<span class='object_link'><a href="Porolog.html#predicate-instance_method" title="Porolog#predicate (method)">#predicate</a></span>
|
290
|
+
<small>Porolog</small>
|
291
|
+
</div>
|
292
|
+
</li>
|
293
|
+
|
294
|
+
|
295
|
+
<li class="even ">
|
296
|
+
<div class="item">
|
297
|
+
<span class='object_link'><a href="Porolog/Scope.html#predicates-instance_method" title="Porolog::Scope#predicates (method)">#predicates</a></span>
|
298
|
+
<small>Porolog::Scope</small>
|
299
|
+
</div>
|
300
|
+
</li>
|
301
|
+
|
302
|
+
|
303
|
+
<li class="odd ">
|
304
|
+
<div class="item">
|
305
|
+
<span class='object_link'><a href="Porolog/Arguments.html#reset-class_method" title="Porolog::Arguments.reset (method)">reset</a></span>
|
306
|
+
<small>Porolog::Arguments</small>
|
307
|
+
</div>
|
308
|
+
</li>
|
309
|
+
|
310
|
+
|
311
|
+
<li class="even ">
|
312
|
+
<div class="item">
|
313
|
+
<span class='object_link'><a href="Porolog/Scope.html#reset-class_method" title="Porolog::Scope.reset (method)">reset</a></span>
|
314
|
+
<small>Porolog::Scope</small>
|
315
|
+
</div>
|
316
|
+
</li>
|
317
|
+
|
318
|
+
|
319
|
+
<li class="odd ">
|
320
|
+
<div class="item">
|
321
|
+
<span class='object_link'><a href="Porolog/Predicate.html#reset-class_method" title="Porolog::Predicate.reset (method)">reset</a></span>
|
322
|
+
<small>Porolog::Predicate</small>
|
323
|
+
</div>
|
324
|
+
</li>
|
325
|
+
|
326
|
+
|
327
|
+
<li class="even ">
|
328
|
+
<div class="item">
|
329
|
+
<span class='object_link'><a href="Porolog/Predicate.html#rules-instance_method" title="Porolog::Predicate#rules (method)">#rules</a></span>
|
330
|
+
<small>Porolog::Predicate</small>
|
331
|
+
</div>
|
332
|
+
</li>
|
333
|
+
|
334
|
+
|
335
|
+
<li class="odd ">
|
336
|
+
<div class="item">
|
337
|
+
<span class='object_link'><a href="Porolog/Predicate.html#scope-class_method" title="Porolog::Predicate.scope (method)">scope</a></span>
|
338
|
+
<small>Porolog::Predicate</small>
|
339
|
+
</div>
|
340
|
+
</li>
|
341
|
+
|
342
|
+
|
343
|
+
<li class="even ">
|
344
|
+
<div class="item">
|
345
|
+
<span class='object_link'><a href="Porolog/Predicate.html#scope=-class_method" title="Porolog::Predicate.scope= (method)">scope=</a></span>
|
346
|
+
<small>Porolog::Predicate</small>
|
347
|
+
</div>
|
348
|
+
</li>
|
349
|
+
|
350
|
+
|
351
|
+
<li class="odd ">
|
352
|
+
<div class="item">
|
353
|
+
<span class='object_link'><a href="Porolog/Scope.html#scopes-class_method" title="Porolog::Scope.scopes (method)">scopes</a></span>
|
354
|
+
<small>Porolog::Scope</small>
|
355
|
+
</div>
|
356
|
+
</li>
|
357
|
+
|
358
|
+
|
359
|
+
<li class="even ">
|
360
|
+
<div class="item">
|
361
|
+
<span class='object_link'><a href="Porolog/Arguments.html#solutions-instance_method" title="Porolog::Arguments#solutions (method)">#solutions</a></span>
|
362
|
+
<small>Porolog::Arguments</small>
|
363
|
+
</div>
|
364
|
+
</li>
|
365
|
+
|
366
|
+
|
367
|
+
<li class="odd ">
|
368
|
+
<div class="item">
|
369
|
+
<span class='object_link'><a href="Porolog/Arguments.html#solve-instance_method" title="Porolog::Arguments#solve (method)">#solve</a></span>
|
370
|
+
<small>Porolog::Arguments</small>
|
371
|
+
</div>
|
372
|
+
</li>
|
373
|
+
|
374
|
+
|
375
|
+
<li class="even ">
|
376
|
+
<div class="item">
|
377
|
+
<span class='object_link'><a href="Porolog/Arguments.html#solve_for-instance_method" title="Porolog::Arguments#solve_for (method)">#solve_for</a></span>
|
378
|
+
<small>Porolog::Arguments</small>
|
379
|
+
</div>
|
380
|
+
</li>
|
381
|
+
|
382
|
+
|
383
|
+
<li class="odd ">
|
384
|
+
<div class="item">
|
385
|
+
<span class='object_link'><a href="Porolog/Arguments.html#valid%3F-instance_method" title="Porolog::Arguments#valid? (method)">#valid?</a></span>
|
386
|
+
<small>Porolog::Arguments</small>
|
387
|
+
</div>
|
388
|
+
</li>
|
389
|
+
|
390
|
+
|
391
|
+
<li class="even ">
|
392
|
+
<div class="item">
|
393
|
+
<span class='object_link'><a href="Porolog/Arguments.html#variables-instance_method" title="Porolog::Arguments#variables (method)">#variables</a></span>
|
394
|
+
<small>Porolog::Arguments</small>
|
395
|
+
</div>
|
396
|
+
</li>
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
</ul>
|
401
|
+
</div>
|
402
|
+
</body>
|
403
|
+
</html>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.19
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Top Level Namespace</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Top Level Namespace
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<h2>Defined Under Namespace</h2>
|
82
|
+
<p class="children">
|
83
|
+
|
84
|
+
|
85
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
</p>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div id="footer">
|
103
|
+
Generated on Mon Apr 22 16:27:39 2019 by
|
104
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
+
0.9.19 (ruby-2.3.4).
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</body>
|
110
|
+
</html>
|
@@ -0,0 +1,173 @@
|
|
1
|
+
#
|
2
|
+
# lib/porolog/arguments.rb - Plain Old Ruby Objects Prolog Engine -- Arguments
|
3
|
+
#
|
4
|
+
# Luis Esteban 2 May 2018
|
5
|
+
# created
|
6
|
+
#
|
7
|
+
|
8
|
+
module Porolog
|
9
|
+
|
10
|
+
# A Porolog::Arguments specifies arguments of a Predicate.
|
11
|
+
# A predicate is not like a subroutine, although there are many similarities.
|
12
|
+
# An Arguments represents an instance of a predicate with a specific set of arguments.
|
13
|
+
# This forms the basis for implementing a goal to solve the predicate with those specific arguments.
|
14
|
+
# @author Luis Esteban
|
15
|
+
# @!attribute [r] predicate
|
16
|
+
# The Predicate for which these are the arguments.
|
17
|
+
# @!attribute [r] arguments
|
18
|
+
# The actual arguments.
|
19
|
+
class Arguments
|
20
|
+
|
21
|
+
attr_reader :predicate, :arguments
|
22
|
+
|
23
|
+
# Unregisters all Arguments
|
24
|
+
# @return [true]
|
25
|
+
def self.reset
|
26
|
+
@@arguments = []
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
reset
|
31
|
+
|
32
|
+
# Creates a new Arguments for a Predicate
|
33
|
+
# @param predicate [Porolog::Predicate] the Predicate for which these are the arguments
|
34
|
+
# @param arguments [Array<Object>] the actual arguments
|
35
|
+
def initialize(predicate, arguments)
|
36
|
+
@predicate = predicate
|
37
|
+
@arguments = arguments
|
38
|
+
@@arguments << self
|
39
|
+
end
|
40
|
+
|
41
|
+
# Convenience method for testing/debugging
|
42
|
+
# @return [Array<Porolog::Arguments>] all registered Arguments
|
43
|
+
def self.arguments
|
44
|
+
@@arguments
|
45
|
+
end
|
46
|
+
|
47
|
+
# Convenience method for testing/debugging
|
48
|
+
# @return [String] pretty identification
|
49
|
+
def myid
|
50
|
+
"Arguments#{(@@arguments.index(self) || -1000) + 1}"
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [String] pretty representation
|
54
|
+
def inspect
|
55
|
+
"#{@predicate.name}(#{@arguments && @arguments.map(&:inspect).join(',')})"
|
56
|
+
end
|
57
|
+
|
58
|
+
# Creates a fact rule that states that these arguments satisfy the Predicate.
|
59
|
+
# @return [Porolog::Arguments] the Arguments
|
60
|
+
def fact!
|
61
|
+
@predicate << Rule.new(self, true)
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
# Creates a fact rule that states that these arguments do not satisfy the Predicate.
|
66
|
+
# @return [Porolog::Arguments] the Arguments
|
67
|
+
def falicy!
|
68
|
+
@predicate << Rule.new(self, false)
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
# Creates a fact rule that states that these arguments satisfy the Predicate and terminates solving the predicate.
|
73
|
+
# @return [Porolog::Arguments] the Arguments
|
74
|
+
def cut_fact!
|
75
|
+
@predicate << Rule.new(self, [:CUT, true])
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
# Creates a fact rule that states that these arguments do not satisfy the Predicate and terminates solving the predicate.
|
80
|
+
# @return [Porolog::Arguments] the Arguments
|
81
|
+
def cut_falicy!
|
82
|
+
@predicate << Rule.new(self, [:CUT, false])
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
# Adds a Rule to the Predicate for these Arguments
|
87
|
+
# @param definition [Array<Object>, Object] the Rule definition for these Arguments
|
88
|
+
# @return [Porolog::Arguments] the Arguments
|
89
|
+
def <<(*definition)
|
90
|
+
@predicate << Rule.new(self, *definition)
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
# Adds an evaluation Rule to the Predicate
|
95
|
+
# @param block the block to evaluate
|
96
|
+
# @return [Porolog::Arguments] the Arguments
|
97
|
+
def evaluates(&block)
|
98
|
+
@predicate << Rule.new(self, block)
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# @return [Array<Symbol>] the variables contained in the arguments
|
103
|
+
def variables
|
104
|
+
@arguments.map{|argument|
|
105
|
+
argument.variables
|
106
|
+
}.flatten.uniq
|
107
|
+
end
|
108
|
+
|
109
|
+
# Creates a Goal for solving this Arguments for the Predicate
|
110
|
+
# @param calling_goal [Porolog::Goal] the parent Goal (if this is a subgoal)
|
111
|
+
# @return [Porolog::Goal] the Goal to solve
|
112
|
+
def goal(calling_goal = nil)
|
113
|
+
Goal.new(self, calling_goal)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns memoized solutions
|
117
|
+
# @param number [Integer] the maximum number of solutions to find (nil means find all)
|
118
|
+
# @return [Array<Hash>] the solutions found (memoized)
|
119
|
+
def solutions(number = nil)
|
120
|
+
@solutions ||= solve(number)
|
121
|
+
@solutions
|
122
|
+
end
|
123
|
+
|
124
|
+
# Solves the Arguments
|
125
|
+
# @param number_of_solutions [Integer] the maximum number of solutions to find (nil means find all)
|
126
|
+
# @return [Array<Hash>] the solutions found
|
127
|
+
def solve(number_of_solutions = nil)
|
128
|
+
@solutions = goal.solve(number_of_solutions)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Extracts solution values.
|
132
|
+
# @param variables [Symbol, Array<Symbol>] variable or variables
|
133
|
+
# @return [Array<Object>] all the values for the variables given
|
134
|
+
# @example
|
135
|
+
# predicate :treasure_at
|
136
|
+
# treasure_at(:X,:Y) << [...]
|
137
|
+
# arguments = treasure_at(:X,:Y)
|
138
|
+
# xs = arguments.solve_for(:X)
|
139
|
+
# ys = arguments.solve_for(:Y)
|
140
|
+
# coords = xs.zip(ys)
|
141
|
+
def solve_for(*variables)
|
142
|
+
variables = [*variables]
|
143
|
+
solutions.map{|solution|
|
144
|
+
variables.map{|variable| solution[variable] }
|
145
|
+
}
|
146
|
+
end
|
147
|
+
|
148
|
+
# @return [Boolean] whether any solutions were found
|
149
|
+
def valid?
|
150
|
+
!solutions.empty?
|
151
|
+
end
|
152
|
+
|
153
|
+
# Duplicates the Arguments in the context of the given goal
|
154
|
+
# @param goal [Porolog::Goal] the destination goal
|
155
|
+
# @return [Porolog::Arguments] the duplicated Arguments
|
156
|
+
def dup(goal)
|
157
|
+
arguments_dup = arguments.dup
|
158
|
+
(0...arguments_dup.size).each do |i|
|
159
|
+
arguments_dup[i] = arguments_dup[i].dup(goal) if arguments_dup[i].is_a?(HeadTail)
|
160
|
+
end
|
161
|
+
self.class.new @predicate, arguments_dup
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param other [Porolog::Arguments] arguments for comparison
|
165
|
+
# @return [Boolean] whether the Arguments match
|
166
|
+
def ==(other)
|
167
|
+
@predicate == other.predicate &&
|
168
|
+
@arguments == other.arguments
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|