porolog 1.0.2 → 1.0.3

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.
@@ -491,7 +491,7 @@
491
491
  </div>
492
492
 
493
493
  <div id="footer">
494
- Generated on Sat Aug 8 08:28:24 2020 by
494
+ Generated on Thu Aug 13 22:35:32 2020 by
495
495
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
496
496
  0.9.19 (ruby-2.6.5).
497
497
  </div>
@@ -451,7 +451,7 @@
451
451
  </div>
452
452
 
453
453
  <div id="footer">
454
- Generated on Sat Aug 8 08:28:23 2020 by
454
+ Generated on Thu Aug 13 22:35:30 2020 by
455
455
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
456
456
  0.9.19 (ruby-2.6.5).
457
457
  </div>
@@ -64,7 +64,7 @@
64
64
 
65
65
  <p>Plain Old Ruby Objects Prolog</p>
66
66
 
67
- <p><a href="https://badge.fury.io/rb/porolog"><img src="https://badge.fury.io/rb/porolog.svg"></a> <a href="https://travis-ci.com/wizardofosmium/porolog"><img src="https://travis-ci.com/wizardofosmium/porolog.svg?branch=master"></a> <a href="https://github.com/wizardofosmium/porolog"><img src="https://github.com/wizardofosmium/porolog/blob/master/coverage/badge.svg"></a></p>
67
+ <p><a href="https://badge.fury.io/rb/porolog"><img src="https://badge.fury.io/rb/porolog.svg"></a> <a href="https://travis-ci.com/wizardofosmium/porolog"><img src="https://travis-ci.com/wizardofosmium/porolog.svg?branch=master"></a> <a href="https://htmlpreview.github.io/?https://github.com/wizardofosmium/porolog/blob/master/coverage/index.html"><img src="https://github.com/wizardofosmium/porolog/blob/master/coverage/badge.svg"></a> <a href="https://www.rubydoc.info/gems/porolog"><img src="https://img.shields.io/badge/documentation-100%2E0%25-brightgreen.svg"></a> <a href="https://github.com/wizardofosmium/porolog/wiki"><img src="https://img.shields.io/badge/wiki-in%20progress-brightgreen.svg"></a></p>
68
68
 
69
69
  <h2 id="label-Introduction">Introduction</h2>
70
70
 
@@ -72,7 +72,7 @@
72
72
 
73
73
  <p>The need that this gem aims to meet is to have a Ruby program interact with a Prolog program using native Ruby objects (POROs); hence the name Porolog. The goal was to implement a minimal logic engine in the style of Prolog where Ruby objects could be passed in and Ruby objects were passed back.</p>
74
74
 
75
- <p>This version completes the minimal/generic logic engine along with some standard builtin predicates. Custom builtin predicates can be easily added.</p>
75
+ <p>This version completes modularisation, so that <code>include Porolog</code> is no longer required.</p>
76
76
 
77
77
  <h2 id="label-Dependencies">Dependencies</h2>
78
78
 
@@ -124,10 +124,11 @@
124
124
 
125
125
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>porolog</span><span class='tstring_end'>&#39;</span></span>
126
126
 
127
- <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
128
-
129
127
  <span class='kw'>class</span> <span class='const'>Numbers</span>
130
128
 
129
+ <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
130
+ <span class='id identifier rubyid_extend'>extend</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
131
+
131
132
  <span class='const'>Predicate</span><span class='period'>.</span><span class='id identifier rubyid_scope'>scope</span> <span class='kw'>self</span>
132
133
  <span class='id identifier rubyid_predicate'>predicate</span> <span class='symbol'>:prime</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
133
134
 
@@ -223,13 +224,11 @@
223
224
 
224
225
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>porolog</span><span class='tstring_end'>&#39;</span></span>
225
226
 
226
- <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
227
-
228
227
  <span class='kw'>class</span> <span class='const'>Numbers</span>
229
228
 
230
- <span class='const'>Predicate</span><span class='period'>.</span><span class='id identifier rubyid_scope'>scope</span> <span class='kw'>self</span>
231
- <span class='id identifier rubyid_builtin'>builtin</span> <span class='symbol'>:gtr</span><span class='comma'>,</span> <span class='symbol'>:is</span><span class='comma'>,</span> <span class='symbol'>:noteq</span><span class='comma'>,</span> <span class='symbol'>:between</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
232
- <span class='id identifier rubyid_predicate'>predicate</span> <span class='symbol'>:prime</span><span class='comma'>,</span> <span class='symbol'>:search_prime</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
229
+ <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Porolog/Predicate.html" title="Porolog::Predicate (class)">Predicate</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scope'><span class='object_link'><a href="Porolog/Predicate.html#scope-class_method" title="Porolog::Predicate.scope (method)">scope</a></span></span> <span class='kw'>self</span>
230
+ <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span><span class='op'>::</span><span class='id identifier rubyid_builtin'><span class='object_link'><a href="Porolog.html#builtin-instance_method" title="Porolog#builtin (method)">builtin</a></span></span> <span class='symbol'>:gtr</span><span class='comma'>,</span> <span class='symbol'>:is</span><span class='comma'>,</span> <span class='symbol'>:noteq</span><span class='comma'>,</span> <span class='symbol'>:between</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
231
+ <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span><span class='op'>::</span><span class='id identifier rubyid_predicate'><span class='object_link'><a href="Porolog.html#predicate-instance_method" title="Porolog#predicate (method)">predicate</a></span></span> <span class='symbol'>:prime</span><span class='comma'>,</span> <span class='symbol'>:search_prime</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
233
232
 
234
233
  <span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_fact!'>fact!</span>
235
234
  <span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_fact!'>fact!</span>
@@ -254,6 +253,10 @@
254
253
  <span class='symbol'>:CUT</span><span class='comma'>,</span>
255
254
  <span class='id identifier rubyid_search_prime'>search_prime</span><span class='lparen'>(</span><span class='symbol'>:X</span><span class='comma'>,</span> <span class='symbol'>:M</span><span class='rparen'>)</span><span class='comma'>,</span>
256
255
  <span class='rbracket'>]</span>
256
+
257
+ <span class='comment'># Unexpose `search_prime`
258
+ </span> <span class='id identifier rubyid_private'>private</span> <span class='symbol'>:search_prime</span>
259
+ <span class='id identifier rubyid_private_class_method'>private_class_method</span> <span class='symbol'>:search_prime</span>
257
260
 
258
261
  <span class='kw'>def</span> <span class='id identifier rubyid_show_primes'>show_primes</span>
259
262
  <span class='id identifier rubyid_solutions'>solutions</span> <span class='op'>=</span> <span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='symbol'>:X</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_solve'>solve</span>
@@ -282,11 +285,15 @@
282
285
  <span class='kw'>end</span>
283
286
 
284
287
 
285
- <span class='id identifier rubyid_numbers'>numbers</span> <span class='op'>=</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='int'>23</span>
286
- <span class='id identifier rubyid_numbers'>numbers</span><span class='period'>.</span><span class='id identifier rubyid_show_primes'>show_primes</span>
287
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_numbers'>numbers</span><span class='period'>.</span><span class='id identifier rubyid_primes'>primes</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
288
+ <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_show_primes'>show_primes</span>
289
+ <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='int'>23</span>
290
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_primes'>primes</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
291
+
292
+ <span class='comment'># `prime` predicate is exposed as a class method
293
+ </span><span class='id identifier rubyid_puts'>puts</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
288
294
 
289
- <span class='id identifier rubyid_puts'>puts</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
295
+ <span class='comment'># `prime` predicate is exposed as an instance method
296
+ </span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
290
297
 
291
298
  <span class='id identifier rubyid_puts'>puts</span> <span class='const'>ARGV</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
292
299
  <span class='const'>ARGV</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_i</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
@@ -318,6 +325,7 @@
318
325
  <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_value_test'>value_test</span>
319
326
  <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_tail_test'>tail_test</span>
320
327
  <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_instantiation_test'>instantiation_test</span>
328
+ <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_samples_test'>samples_test</span>
321
329
  </code></pre>
322
330
 
323
331
  <h2 id="label-Author">Author</h2>
@@ -326,7 +334,7 @@
326
334
  </div></div>
327
335
 
328
336
  <div id="footer">
329
- Generated on Sat Aug 8 08:28:23 2020 by
337
+ Generated on Thu Aug 13 22:35:30 2020 by
330
338
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
331
339
  0.9.19 (ruby-2.6.5).
332
340
  </div>
@@ -64,7 +64,7 @@
64
64
 
65
65
  <p>Plain Old Ruby Objects Prolog</p>
66
66
 
67
- <p><a href="https://badge.fury.io/rb/porolog"><img src="https://badge.fury.io/rb/porolog.svg"></a> <a href="https://travis-ci.com/wizardofosmium/porolog"><img src="https://travis-ci.com/wizardofosmium/porolog.svg?branch=master"></a> <a href="https://github.com/wizardofosmium/porolog"><img src="https://github.com/wizardofosmium/porolog/blob/master/coverage/badge.svg"></a></p>
67
+ <p><a href="https://badge.fury.io/rb/porolog"><img src="https://badge.fury.io/rb/porolog.svg"></a> <a href="https://travis-ci.com/wizardofosmium/porolog"><img src="https://travis-ci.com/wizardofosmium/porolog.svg?branch=master"></a> <a href="https://htmlpreview.github.io/?https://github.com/wizardofosmium/porolog/blob/master/coverage/index.html"><img src="https://github.com/wizardofosmium/porolog/blob/master/coverage/badge.svg"></a> <a href="https://www.rubydoc.info/gems/porolog"><img src="https://img.shields.io/badge/documentation-100%2E0%25-brightgreen.svg"></a> <a href="https://github.com/wizardofosmium/porolog/wiki"><img src="https://img.shields.io/badge/wiki-in%20progress-brightgreen.svg"></a></p>
68
68
 
69
69
  <h2 id="label-Introduction">Introduction</h2>
70
70
 
@@ -72,7 +72,7 @@
72
72
 
73
73
  <p>The need that this gem aims to meet is to have a Ruby program interact with a Prolog program using native Ruby objects (POROs); hence the name Porolog. The goal was to implement a minimal logic engine in the style of Prolog where Ruby objects could be passed in and Ruby objects were passed back.</p>
74
74
 
75
- <p>This version completes the minimal/generic logic engine along with some standard builtin predicates. Custom builtin predicates can be easily added.</p>
75
+ <p>This version completes modularisation, so that <code>include Porolog</code> is no longer required.</p>
76
76
 
77
77
  <h2 id="label-Dependencies">Dependencies</h2>
78
78
 
@@ -124,10 +124,11 @@
124
124
 
125
125
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>porolog</span><span class='tstring_end'>&#39;</span></span>
126
126
 
127
- <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
128
-
129
127
  <span class='kw'>class</span> <span class='const'>Numbers</span>
130
128
 
129
+ <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
130
+ <span class='id identifier rubyid_extend'>extend</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
131
+
131
132
  <span class='const'>Predicate</span><span class='period'>.</span><span class='id identifier rubyid_scope'>scope</span> <span class='kw'>self</span>
132
133
  <span class='id identifier rubyid_predicate'>predicate</span> <span class='symbol'>:prime</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
133
134
 
@@ -223,13 +224,11 @@
223
224
 
224
225
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>porolog</span><span class='tstring_end'>&#39;</span></span>
225
226
 
226
- <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span>
227
-
228
227
  <span class='kw'>class</span> <span class='const'>Numbers</span>
229
228
 
230
- <span class='const'>Predicate</span><span class='period'>.</span><span class='id identifier rubyid_scope'>scope</span> <span class='kw'>self</span>
231
- <span class='id identifier rubyid_builtin'>builtin</span> <span class='symbol'>:gtr</span><span class='comma'>,</span> <span class='symbol'>:is</span><span class='comma'>,</span> <span class='symbol'>:noteq</span><span class='comma'>,</span> <span class='symbol'>:between</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
232
- <span class='id identifier rubyid_predicate'>predicate</span> <span class='symbol'>:prime</span><span class='comma'>,</span> <span class='symbol'>:search_prime</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
229
+ <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Porolog/Predicate.html" title="Porolog::Predicate (class)">Predicate</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scope'><span class='object_link'><a href="Porolog/Predicate.html#scope-class_method" title="Porolog::Predicate.scope (method)">scope</a></span></span> <span class='kw'>self</span>
230
+ <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span><span class='op'>::</span><span class='id identifier rubyid_builtin'><span class='object_link'><a href="Porolog.html#builtin-instance_method" title="Porolog#builtin (method)">builtin</a></span></span> <span class='symbol'>:gtr</span><span class='comma'>,</span> <span class='symbol'>:is</span><span class='comma'>,</span> <span class='symbol'>:noteq</span><span class='comma'>,</span> <span class='symbol'>:between</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
231
+ <span class='const'><span class='object_link'><a href="Porolog.html" title="Porolog (module)">Porolog</a></span></span><span class='op'>::</span><span class='id identifier rubyid_predicate'><span class='object_link'><a href="Porolog.html#predicate-instance_method" title="Porolog#predicate (method)">predicate</a></span></span> <span class='symbol'>:prime</span><span class='comma'>,</span> <span class='symbol'>:search_prime</span><span class='comma'>,</span> <span class='label'>class_base:</span> <span class='kw'>self</span>
233
232
 
234
233
  <span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_fact!'>fact!</span>
235
234
  <span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_fact!'>fact!</span>
@@ -254,6 +253,10 @@
254
253
  <span class='symbol'>:CUT</span><span class='comma'>,</span>
255
254
  <span class='id identifier rubyid_search_prime'>search_prime</span><span class='lparen'>(</span><span class='symbol'>:X</span><span class='comma'>,</span> <span class='symbol'>:M</span><span class='rparen'>)</span><span class='comma'>,</span>
256
255
  <span class='rbracket'>]</span>
256
+
257
+ <span class='comment'># Unexpose `search_prime`
258
+ </span> <span class='id identifier rubyid_private'>private</span> <span class='symbol'>:search_prime</span>
259
+ <span class='id identifier rubyid_private_class_method'>private_class_method</span> <span class='symbol'>:search_prime</span>
257
260
 
258
261
  <span class='kw'>def</span> <span class='id identifier rubyid_show_primes'>show_primes</span>
259
262
  <span class='id identifier rubyid_solutions'>solutions</span> <span class='op'>=</span> <span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='symbol'>:X</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_solve'>solve</span>
@@ -282,11 +285,15 @@
282
285
  <span class='kw'>end</span>
283
286
 
284
287
 
285
- <span class='id identifier rubyid_numbers'>numbers</span> <span class='op'>=</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='int'>23</span>
286
- <span class='id identifier rubyid_numbers'>numbers</span><span class='period'>.</span><span class='id identifier rubyid_show_primes'>show_primes</span>
287
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_numbers'>numbers</span><span class='period'>.</span><span class='id identifier rubyid_primes'>primes</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
288
+ <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_show_primes'>show_primes</span>
289
+ <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='int'>23</span>
290
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_primes'>primes</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
291
+
292
+ <span class='comment'># `prime` predicate is exposed as a class method
293
+ </span><span class='id identifier rubyid_puts'>puts</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
288
294
 
289
- <span class='id identifier rubyid_puts'>puts</span> <span class='const'>Numbers</span><span class='period'>.</span><span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
295
+ <span class='comment'># `prime` predicate is exposed as an instance method
296
+ </span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_prime'>prime</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
290
297
 
291
298
  <span class='id identifier rubyid_puts'>puts</span> <span class='const'>ARGV</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
292
299
  <span class='const'>ARGV</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_i</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
@@ -318,6 +325,7 @@
318
325
  <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_value_test'>value_test</span>
319
326
  <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_tail_test'>tail_test</span>
320
327
  <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_instantiation_test'>instantiation_test</span>
328
+ <span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_samples_test'>samples_test</span>
321
329
  </code></pre>
322
330
 
323
331
  <h2 id="label-Author">Author</h2>
@@ -326,7 +334,7 @@
326
334
  </div></div>
327
335
 
328
336
  <div id="footer">
329
- Generated on Sat Aug 8 08:28:23 2020 by
337
+ Generated on Thu Aug 13 22:35:30 2020 by
330
338
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
331
339
  0.9.19 (ruby-2.6.5).
332
340
  </div>
@@ -102,7 +102,7 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Sat Aug 8 08:28:23 2020 by
105
+ Generated on Thu Aug 13 22:35:30 2020 by
106
106
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
107
  0.9.19 (ruby-2.6.5).
108
108
  </div>
@@ -10,10 +10,12 @@
10
10
  #
11
11
  module Porolog
12
12
 
13
+ extend self
14
+
13
15
  # The most recent version of the Porolog gem.
14
- VERSION = '1.0.2'.freeze
16
+ VERSION = '1.0.3'.freeze
15
17
  # The most recent date of when the VERSION changed.
16
- VERSION_DATE = '2020-08-08'.freeze
18
+ VERSION_DATE = '2020-08-13'.freeze
17
19
 
18
20
  # Represents an unknown tail of a list.
19
21
  UNKNOWN_TAIL = Object.new
@@ -93,15 +93,15 @@ class Array
93
93
  return self if visited.include?(self)
94
94
  visited = visited + [self]
95
95
  flat_map{|element|
96
- if element.is_a?(Tail)
96
+ if element.is_a?(Porolog::Tail)
97
97
  tail = element.value(visited)
98
98
  if tail.is_a?(Array)
99
99
  tail
100
- elsif tail.is_a?(Variable) || tail.is_a?(Value)
100
+ elsif tail.is_a?(Porolog::Variable) || tail.is_a?(Porolog::Value)
101
101
  tail = tail.value(visited)
102
102
  if tail.is_a?(Array)
103
103
  tail
104
- elsif tail.is_a?(Variable) || tail.is_a?(Value)
104
+ elsif tail.is_a?(Porolog::Variable) || tail.is_a?(Porolog::Value)
105
105
  tail = tail.goal.variablise(tail.value(visited))
106
106
  if tail.is_a?(Array)
107
107
  tail
@@ -126,9 +126,9 @@ class Array
126
126
  value.map{|element|
127
127
  if element.is_a?(Array)
128
128
  element.clean
129
- elsif element.is_a?(Tail)
130
- UNKNOWN_TAIL
131
- elsif element.is_a?(Variable)
129
+ elsif element.is_a?(Porolog::Tail)
130
+ Porolog::UNKNOWN_TAIL
131
+ elsif element.is_a?(Porolog::Variable)
132
132
  nil
133
133
  else
134
134
  element.value
@@ -145,7 +145,7 @@ class Array
145
145
  # @return [Array] an Array with the Object being the head and the other Object being the tail.
146
146
  def /(other)
147
147
  if other.is_a?(Porolog::Variable) || other.is_a?(Symbol)
148
- self + [Tail.new(other)]
148
+ self + [Porolog::Tail.new(other)]
149
149
  else
150
150
  self + [*other]
151
151
  end
@@ -177,7 +177,7 @@ class Array
177
177
 
178
178
  # @return [Boolean] whether the Object is an Array with a head and a tail.
179
179
  def headtail?
180
- length == 2 && (last.is_a?(Tail) || last == UNKNOWN_TAIL)
180
+ length == 2 && (last.is_a?(Porolog::Tail) || last == Porolog::UNKNOWN_TAIL)
181
181
  end
182
182
 
183
183
  # @return [Porolog::Goal] the goal that is most likely to be the goal for this array.
@@ -336,7 +336,7 @@ module Porolog
336
336
  variables.each do |variable|
337
337
  name = variable
338
338
 
339
- unification = unify(name, name, other_goal, self)
339
+ unification = Porolog::unify(name, name, other_goal, self)
340
340
  unified &&= !!unification
341
341
  if unified
342
342
  unifications += unification
@@ -347,7 +347,7 @@ module Porolog
347
347
  #:nocov:
348
348
  end
349
349
  end
350
- unified &&= instantiate_unifications(unifications) if unified
350
+ unified &&= Porolog::instantiate_unifications(unifications) if unified
351
351
 
352
352
  unified
353
353
  end
@@ -280,7 +280,7 @@ module Porolog
280
280
  all_values = all_values.map(&:value).map(&:value)
281
281
  exclusions = exclusions.map(&:value).map(&:value)
282
282
 
283
- possible_values = goal[anonymous]
283
+ possible_values = goal[Porolog::anonymous]
284
284
 
285
285
  if exclusions.uniq.size == exclusions.size
286
286
  !!possible_values.instantiate(all_values - exclusions) && Predicate.call_builtin(:member, goal, block, variable, possible_values) || false
@@ -435,7 +435,7 @@ module Porolog
435
435
  when [:array, :atomic]
436
436
  list.length == length
437
437
  when [:variable, :atomic]
438
- list.instantiate(Array.new(length){goal[_]})
438
+ list.instantiate(Array.new(length){goal[Porolog::anonymous]})
439
439
  when [:array, :variable]
440
440
  length.instantiate(list.length)
441
441
  else
@@ -533,9 +533,9 @@ module Porolog
533
533
  when [:atomic, :array], [:array, :array]
534
534
  satisfied = false
535
535
  list.each do |i|
536
- unifications = unify(element_value, i, goal)
536
+ unifications = Porolog::unify(element_value, i, goal)
537
537
  if unifications
538
- instantiations = instantiate_unifications(unifications)
538
+ instantiations = Porolog::instantiate_unifications(unifications)
539
539
  if instantiations
540
540
  block.call(goal) && (satisfied = true)
541
541
  instantiations.each(&:remove)
@@ -560,7 +560,7 @@ module Porolog
560
560
  when [:variable, :variable], [:atomic, :variable], [:array, :variable]
561
561
  satisfied = false
562
562
  limit.times do |i|
563
- instantiation = list.instantiate([*Array.new(i){goal[_]}, element, UNKNOWN_TAIL])
563
+ instantiation = list.instantiate([*Array.new(i){goal[Porolog::anonymous]}, element, Porolog::UNKNOWN_TAIL])
564
564
  instantiation && block.call(goal) && (satisfied = true)
565
565
  instantiation&.remove
566
566
  return satisfied if goal.terminated?
@@ -600,8 +600,8 @@ module Porolog
600
600
  when [:array, :array, :array]
601
601
  satisfied = false
602
602
  if front.length + back.length == front_back.length
603
- unifications = unify(front + back, front_back, goal)
604
- instantiations = instantiate_unifications(unifications) if unifications
603
+ unifications = Porolog::unify(front + back, front_back, goal)
604
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
605
605
  instantiations && block.call(goal) && (satisfied = true)
606
606
  instantiations&.each(&:remove)
607
607
  end
@@ -609,8 +609,8 @@ module Porolog
609
609
 
610
610
  when [:array, :array, :variable]
611
611
  satisfied = false
612
- unifications = unify(front + back, front_back, goal)
613
- instantiations = instantiate_unifications(unifications) if unifications
612
+ unifications = Porolog::unify(front + back, front_back, goal)
613
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
614
614
  instantiations && block.call(goal) && (satisfied = true)
615
615
  instantiations&.each(&:remove)
616
616
  satisfied
@@ -621,9 +621,9 @@ module Porolog
621
621
  expected_front = front_back[0...front.length]
622
622
  expected_back = front_back[front.length..-1]
623
623
 
624
- unifications = unify(front, expected_front, goal)
625
- unifications += unify(back, expected_back, goal) if unifications
626
- instantiations = instantiate_unifications(unifications) if unifications
624
+ unifications = Porolog::unify(front, expected_front, goal)
625
+ unifications += Porolog::unify(back, expected_back, goal) if unifications
626
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
627
627
  instantiations && block.call(goal) && (satisfied = true)
628
628
  instantiations&.each(&:remove)
629
629
  end
@@ -635,9 +635,9 @@ module Porolog
635
635
  expected_front = front_back[0...-back.length]
636
636
  expected_back = front_back[-back.length..-1]
637
637
 
638
- unifications = unify(front, expected_front, goal)
639
- unifications += unify(back, expected_back, goal) if unifications
640
- instantiations = instantiate_unifications(unifications) if unifications
638
+ unifications = Porolog::unify(front, expected_front, goal)
639
+ unifications += Porolog::unify(back, expected_back, goal) if unifications
640
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
641
641
  instantiations && block.call(goal) && (satisfied = true)
642
642
  instantiations&.each(&:remove)
643
643
  end
@@ -649,9 +649,9 @@ module Porolog
649
649
  expected_front = front_back[0...i]
650
650
  expected_back = front_back[i..-1]
651
651
 
652
- unifications = unify(front, expected_front, goal)
653
- unifications += unify(back, expected_back, goal) if unifications
654
- instantiations = instantiate_unifications(unifications) if unifications
652
+ unifications = Porolog::unify(front, expected_front, goal)
653
+ unifications += Porolog::unify(back, expected_back, goal) if unifications
654
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
655
655
  instantiations && block.call(goal) && (satisfied = true)
656
656
  instantiations&.each(&:remove)
657
657
  return satisfied if goal.terminated?
@@ -660,8 +660,8 @@ module Porolog
660
660
 
661
661
  when [:array, :variable, :variable]
662
662
  satisfied = false
663
- unifications = unify(front / back, front_back, goal)
664
- instantiations = instantiate_unifications(unifications) if unifications
663
+ unifications = Porolog::unify(front / back, front_back, goal)
664
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
665
665
  instantiations && block.call(goal) && (satisfied = true)
666
666
  instantiations&.each(&:remove)
667
667
  satisfied
@@ -720,16 +720,16 @@ module Porolog
720
720
  list1 = list1.sort_by(&:inspect)
721
721
  list2 = list2.sort_by(&:inspect)
722
722
 
723
- unifications = unify(list1, list2, goal)
724
- instantiations = instantiate_unifications(unifications) if unifications
723
+ unifications = Porolog::unify(list1, list2, goal)
724
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
725
725
  instantiations && block.call(goal) && (satisfied = true)
726
726
  instantiations&.each(&:remove)
727
727
 
728
728
  when [false, true], [false, false]
729
729
  list2.permutation do |p|
730
- unifications = unify(list1, p, goal)
730
+ unifications = Porolog::unify(list1, p, goal)
731
731
  instantiations = nil
732
- instantiations = instantiate_unifications(unifications) if unifications
732
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
733
733
  instantiations && block.call(goal) && (satisfied = true)
734
734
  instantiations&.each(&:remove)
735
735
  return satisfied if goal.terminated?
@@ -737,9 +737,9 @@ module Porolog
737
737
 
738
738
  when [true, false]
739
739
  list1.permutation do |p|
740
- unifications = unify(list2, p, goal)
740
+ unifications = Porolog::unify(list2, p, goal)
741
741
  instantiations = nil
742
- instantiations = instantiate_unifications(unifications) if unifications
742
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
743
743
  instantiations && block.call(goal) && (satisfied = true)
744
744
  instantiations&.each(&:remove)
745
745
  return satisfied if goal.terminated?
@@ -750,8 +750,8 @@ module Porolog
750
750
  when [:array, :variable]
751
751
  satisfied = false
752
752
  list1.permutation do |p|
753
- unifications = unify(p, list2, goal)
754
- instantiations = instantiate_unifications(unifications) if unifications
753
+ unifications = Porolog::unify(p, list2, goal)
754
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
755
755
  instantiations && block.call(goal) && (satisfied = true)
756
756
  instantiations&.each(&:remove)
757
757
  return satisfied if goal.terminated?
@@ -761,9 +761,9 @@ module Porolog
761
761
  when [:variable, :array]
762
762
  satisfied = false
763
763
  list2.permutation do |p|
764
- unifications = unify(list1, p, goal)
764
+ unifications = Porolog::unify(list1, p, goal)
765
765
  instantiations = nil
766
- instantiations = instantiate_unifications(unifications) if unifications
766
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
767
767
  instantiations && block.call(goal) && (satisfied = true)
768
768
  instantiations&.each(&:remove)
769
769
  return satisfied if goal.terminated?
@@ -799,16 +799,16 @@ module Porolog
799
799
  case [list1.type, list2.type]
800
800
  when [:array, :array], [:variable, :array]
801
801
  satisfied = false
802
- unifications = unify(list1, list2.reverse, goal)
803
- instantiations = instantiate_unifications(unifications) if unifications
802
+ unifications = Porolog::unify(list1, list2.reverse, goal)
803
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
804
804
  instantiations && block.call(goal) && (satisfied = true)
805
805
  instantiations&.each(&:remove)
806
806
  satisfied
807
807
 
808
808
  when [:array, :variable]
809
809
  satisfied = false
810
- unifications = unify(list1.reverse, list2, goal)
811
- instantiations = instantiate_unifications(unifications) if unifications
810
+ unifications = Porolog::unify(list1.reverse, list2, goal)
811
+ instantiations = Porolog::instantiate_unifications(unifications) if unifications
812
812
  instantiations && block.call(goal) && (satisfied = true)
813
813
  instantiations&.each(&:remove)
814
814
  satisfied