moory 1.1.3 → 1.1.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/Gemfile.lock +1 -1
- data/examples/consequences.rb +77 -0
- data/examples/inductive.rb +0 -3
- data/lib/moory/logistic.rb +22 -5
- data/lib/moory/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0239942918e89ed21a49acd4fd35cee39ad71910dece516c6f53a04b36f962dd'
|
|
4
|
+
data.tar.gz: bbedc737fdc70d1fc41b8386a30903e7d324301cd11d07adc2264a4f8212a8ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc8b101ebaead0455063763317833d62148f72a6b5e561f81b336d4be88aab781795338fcf98150a67d38635464a5eb1aaf2941fbc454052c700b1770edaa5a9
|
|
7
|
+
data.tar.gz: 5b0cb93badef69d457928f3df86ea6ae9cc7f659c430b13fd0f4e8ed680923dba018a4e83f19043ff5d858fb6cae954c01c5a53c3b44fe15c0845f0956afe5ba
|
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'moory'
|
|
2
|
+
|
|
3
|
+
pipcv_config = {
|
|
4
|
+
basis: 'basis',
|
|
5
|
+
specs: {
|
|
6
|
+
'basis' => {
|
|
7
|
+
rules: """
|
|
8
|
+
^ : constant : $
|
|
9
|
+
|
|
10
|
+
^ : variable : $
|
|
11
|
+
|
|
12
|
+
^ : prefix / open / defer : Δ
|
|
13
|
+
|
|
14
|
+
^ : ( / parenthetical / defer : Δ
|
|
15
|
+
|
|
16
|
+
$ : infix / open / defer : Δ
|
|
17
|
+
|
|
18
|
+
Δ : term : $
|
|
19
|
+
""",
|
|
20
|
+
},
|
|
21
|
+
'open' => {
|
|
22
|
+
rules: """
|
|
23
|
+
^ : constant / term / reconvene : $
|
|
24
|
+
|
|
25
|
+
^ : variable / term / reconvene : $
|
|
26
|
+
|
|
27
|
+
^ : prefix / open / defer : Δ
|
|
28
|
+
|
|
29
|
+
^ : ( / parenthetical / defer : Δ
|
|
30
|
+
|
|
31
|
+
$ : infix / open / defer : Δ
|
|
32
|
+
|
|
33
|
+
Δ : term / term / reconvene : $
|
|
34
|
+
""",
|
|
35
|
+
},
|
|
36
|
+
'parenthetical' => {
|
|
37
|
+
rules: """
|
|
38
|
+
^ : constant : C
|
|
39
|
+
|
|
40
|
+
^ : variable : C
|
|
41
|
+
|
|
42
|
+
^ : prefix / open / defer : Δ
|
|
43
|
+
|
|
44
|
+
^ : ( / parenthetical / defer : Δ
|
|
45
|
+
|
|
46
|
+
^ : ) / void / reconvene : $
|
|
47
|
+
|
|
48
|
+
C : infix / open / defer : Δ
|
|
49
|
+
|
|
50
|
+
C : ) / term / reconvene : $
|
|
51
|
+
|
|
52
|
+
Δ : term : C
|
|
53
|
+
"""
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
logistic = Moory::Logistic::Controller.new(pipcv_config)
|
|
59
|
+
|
|
60
|
+
pp logistic.issue('(')
|
|
61
|
+
pp logistic.issue('(')
|
|
62
|
+
pp logistic.issue('prefix')
|
|
63
|
+
pp logistic.issue('constant')
|
|
64
|
+
pp logistic.issue('infix')
|
|
65
|
+
pp logistic.issue('prefix')
|
|
66
|
+
pp logistic.issue('(')
|
|
67
|
+
pp logistic.issue('variable')
|
|
68
|
+
pp logistic.issue('infix')
|
|
69
|
+
pp logistic.issue('prefix')
|
|
70
|
+
pp logistic.issue('(')
|
|
71
|
+
pp logistic.issue('variable')
|
|
72
|
+
pp logistic.issue(')')
|
|
73
|
+
pp logistic.issue(')')
|
|
74
|
+
pp logistic.issue(')')
|
|
75
|
+
pp logistic.issue(')')
|
|
76
|
+
pp logistic.issue('infix')
|
|
77
|
+
pp logistic.issue('variable')
|
data/examples/inductive.rb
CHANGED
data/lib/moory/logistic.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
module Moory
|
|
2
2
|
module Logistic
|
|
3
|
+
module NilExtensions
|
|
4
|
+
refine NilClass do
|
|
5
|
+
def <<(other);end
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
3
9
|
class Unit
|
|
4
10
|
include Moory::Efferent
|
|
5
11
|
|
|
@@ -27,6 +33,8 @@ module Moory
|
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
class Controller
|
|
36
|
+
using NilExtensions
|
|
37
|
+
|
|
30
38
|
def initialize(config)
|
|
31
39
|
@config = config
|
|
32
40
|
prepare_units
|
|
@@ -51,11 +59,11 @@ module Moory
|
|
|
51
59
|
end
|
|
52
60
|
|
|
53
61
|
def issue(stimulus)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
@consequences = []
|
|
63
|
+
|
|
64
|
+
active_unit.understand?(stimulus) ?
|
|
65
|
+
forward(stimulus) :
|
|
66
|
+
nil
|
|
59
67
|
end
|
|
60
68
|
|
|
61
69
|
private
|
|
@@ -78,8 +86,15 @@ module Moory
|
|
|
78
86
|
def focus_on(unit_name)
|
|
79
87
|
@focus = unit_name
|
|
80
88
|
end
|
|
89
|
+
|
|
90
|
+
def forward(stimulus)
|
|
91
|
+
active_unit.issue(stimulus)
|
|
92
|
+
@consequences
|
|
93
|
+
end
|
|
81
94
|
|
|
82
95
|
def defer(unit_name)
|
|
96
|
+
@consequences << :defer
|
|
97
|
+
|
|
83
98
|
deferrals.push(
|
|
84
99
|
{
|
|
85
100
|
name: @focus.clone,
|
|
@@ -92,6 +107,8 @@ module Moory
|
|
|
92
107
|
|
|
93
108
|
def reconvene(stimulus=nil)
|
|
94
109
|
raise "Cannot reconvene without prior deferral" if deferrals.empty?
|
|
110
|
+
|
|
111
|
+
@consequences << :reconvene
|
|
95
112
|
|
|
96
113
|
deferrals.pop.tap do |last_deferral|
|
|
97
114
|
focus_on(last_deferral[:name])
|
data/lib/moory/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: moory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam W. Grant
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-08-
|
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -70,6 +70,7 @@ files:
|
|
|
70
70
|
- bin/console
|
|
71
71
|
- bin/setup
|
|
72
72
|
- examples/ab_star.rb
|
|
73
|
+
- examples/consequences.rb
|
|
73
74
|
- examples/decoder.rb
|
|
74
75
|
- examples/inductive.rb
|
|
75
76
|
- lib/moory.rb
|